CREATE PROCEDURE [dbo].[OnlineInsertToJournal] @Referencenumber INT, @FileName VARCHAR(255), @FileToSave varbinary(MAX), @DateStamp DATETIME  AS
SET NOCOUNT ON
/*
    Created by Troels Buch Dec 2015

    Changes: N/A
    

    NOTES: 	- 

*/

DECLARE @NewAttachmentNumber INT

INSERT INTO Attachment (Blob, datestamp, FileGroup, AddressTypeNumber, Name, TemplateNumber, Readonly, Batch)
VALUES (@FileToSave, @DateStamp, 2, 0, @FileName, -1, 1, 0)

SELECT @NewAttachmentNumber = @@identity

INSERT INTO ReservationAttachmentXTab (ReferenceNumber, GuestNumber, AttachmentNumber)
VALUES (@Referencenumber, 0, @NewAttachmentNumber)



