
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'ReservationRoomLineBackup')
BEGIN

	CREATE TABLE [dbo].[ReservationRoomLineBackup](
		[LINENUMBER] [int] NOT NULL,
		[BookedTypeNumber] [int] NULL,
		[BOOKEDSUBTYPE] [char](10) NULL,
		[RoomNumber] [int] NULL,
		[NumberOfRooms] [smallint] NOT NULL,
		[ArrivalDate] [char](8) NOT NULL,
		[ArrivalTime] [char](5) NULL,
		[DepartureDate] [char](8) NOT NULL,
		[DepartureTime] [char](5) NULL,
		[Adults] [smallint] NULL,
		[Children1] [smallint] NULL,
		[Children2] [smallint] NULL,
		[ProductNumber] [int] NULL,
		[ProductNumber2] [int] NULL,
		[Day3] [smallint] NULL,
		[ProductNumber3] [int] NULL,
		[Day4] [smallint] NULL,
		[ProductNumber4] [int] NULL,
		[Price] [money] NULL,
		[TotalPrice] [money] NULL,
		[PriceOverwritten] [bit] NULL,
		[ScreenLine] [smallint] NULL,
		[PriceOverwritten2] [bit] NULL,
		[PriceOverwritten3] [bit] NULL,
		[PriceOverwritten4] [bit] NULL,
		[FirstPrice1] [money] NULL,
		[FirstPrice2] [money] NULL,
		[FirstPrice3] [money] NULL,
		[FirstPrice4] [money] NULL,
		[TotalPrice1] [money] NULL,
		[TotalPrice2] [money] NULL,
		[TotalPrice3] [money] NULL,
		[TotalPrice4] [money] NULL,
		[RebookedUnderLineNumber] [int] NULL,
		[NameListSetting] [tinyint] NULL,
		[NameListCreateFlag] [bit] NULL,
		[SplitBillNumber1] [smallint] NULL,
		[SplitBillNumber2] [smallint] NULL,
		[SplitBillNumber3] [smallint] NULL,
		[SplitBillNumber4] [smallint] NULL,
		[AllocationLocked] [bit] NULL,
		[Day2] [smallint] NULL,
		[AutoPlusProduct] [bit] NOT NULL,
		[StatusRL] [int] NULL,
		[FK_ReservationGroup] [int] NULL,
		[FK_CurrencyCountryNumber] [int] NULL,
		[CurrencyRate] [money] NULL,
		[LastUpdDateStamp] [datetime] NOT NULL,
		[InitialNumberOfRooms] [int] NULL,
		[IsChangedManually] [bit] NULL,
		[KeyPinCode] [varchar](50) NULL,
		[PlusProductSamePeriod] [bit] NOT NULL
		
	 CONSTRAINT [PK_RESERVATIONROOMLINEBackup] PRIMARY KEY CLUSTERED 
	(
		[LINENUMBER] DESC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	) ON [PRIMARY]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Adult__66AF1232]  DEFAULT ((0)) FOR [Adults]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Child__67A3366B]  DEFAULT ((0)) FOR [Children1]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Child__68975AA4]  DEFAULT ((0)) FOR [Children2]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Price__698B7EDD]  DEFAULT ((0)) FOR [PriceOverwritten]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Price__6A7FA316]  DEFAULT ((0)) FOR [PriceOverwritten2]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Price__6B73C74F]  DEFAULT ((0)) FOR [PriceOverwritten3]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__Price__6C67EB88]  DEFAULT ((0)) FOR [PriceOverwritten4]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__Tmp_RESERBackup__NameL__6D5C0FC1]  DEFAULT ((0)) FOR [NameListCreateFlag]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF__RESERVATIBackup__AutoP__03563DD8]  DEFAULT ((0)) FOR [AutoPlusProduct]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  CONSTRAINT [DF_ReservationRoomLineBackup_LastUpdDateStamp]  DEFAULT (getdate()) FOR [LastUpdDateStamp]

	ALTER TABLE [dbo].[ReservationRoomLineBackup] ADD  DEFAULT ((0)) FOR [PlusProductSamePeriod]

	CREATE TABLE [dbo].[ReservationRoomlineXTabBackup](
	[ReferenceNumber] [int] NOT NULL,
	[GuestNumber] [smallint] NOT NULL,
	[LINENUMBER] [int] NOT NULL,
	 CONSTRAINT [PK_RESERVATIONROOMLINEXTABBackup] PRIMARY KEY CLUSTERED 
	(
		[ReferenceNumber] DESC,
		[GuestNumber] ASC,
		[LINENUMBER] DESC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	) ON [PRIMARY]


	ALTER TABLE [dbo].[ReservationRoomlineXTabBackup] ADD  CONSTRAINT [DF_RESERVATIONROOMLINEXTABBackup_GuestNumber]  DEFAULT (0) FOR [GuestNumber]


END