IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ArrangementLinesDepDeleted]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[ArrangementLinesDepDeleted](
	  [ReferenceNumber] [int] NOT NULL,
	  [GuestNumber] [int] NOT NULL,
	  [LineNumber] [int] NOT NULL,
	  [PacketItemNumber] [int] NOT NULL,
	  [Date] [char](8) NULL,
	  [Time] [char](5) NULL,
	  [Price] [money] NULL,
	  [WareNumber] [int] NULL,
	  [DepartureTime] [char](5) NULL,
	  [PacketItemTime] [char](5) NULL,
	  [FK_DepartmentNumber] [int] NULL
  ) ON [PRIMARY]
END

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'LineNumber'
    WHERE SysObjects.Name = 'ArrangementLinesDepDeleted'
)
BEGIN
  EXEC sp_rename 'dbo.ArrangementLinesDepDeleted.ArrangementLineNumber', 'LineNumber', 'COLUMN'
END