IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ArrangementLinesDeleted]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[ArrangementLinesDeleted](
   	[ReferenceNumber] [int] NOT NULL,
	[GuestNumber] [int] NOT NULL,
	[LineNumber] [int] NOT NULL,
	[Date] [char](8) NULL,
	[PacketItemNumber] [int] NULL,
	[Time] [char](5) NULL,
	[Price] [money] NULL,
	[TotalPrice]  AS ([Pieces]*[Price]),
	[Pieces] [int] NULL,
	[PlaceText] [varchar](30) NULL,
	[WareNumber] [int] NULL,
	[HallNumber] [int] NULL,
	[Note] [nvarchar](max) NULL,
	[DepartureTime] [char](5) NULL,
	[Priority] [tinyint] NULL,
	[Correction] [int] NULL,
	[FK_ExDepartment] [int] NULL,
	[FK_PacketChargeDepartment] [int] NULL,
	[FK_HallNumber] [int] NULL,
	[WareText] [varchar](80) NULL,
	[FK_HallLineNumber] [int] NULL,
	[ReadOnly] [bit] NULL,
	[AttachedRoomLine] [varchar](50) NULL,
	[FK_CurrencyCountryNumber] [int] NULL,
	[CurrencyRate] [money] NULL,
	[LastUpdDateStamp] [datetime] NOT NULL,
	[IsPiecesUserModified] [bit] NULL,
	[PiecesModifiedDiff] [int] NULL,
	[PacketItemTime] [char](5) NULL
  ) ON [PRIMARY]
END
