CREATE PROCEDURE [dbo].[GA_CreateTempTables] @SpecifyOnRoomTypeSegPos BIT AS
SET NOCOUNT ON

CREATE TABLE #AllotmentLines (
	AllotmentNumber INT,
	RoomTypeNumber INT,
	DateStamp CHAR (8) COLLATE DATABASE_DEFAULT NOT NULL, -- DO NOT REMOVE COLLATION!
	CurrentCount SMALLINT
)
/*
CREATE UNIQUE INDEX #pk_allotmentlines ON #AllotmentLines(
        [AllotmentNumber],
        [RoomTypeNumber],
        [DateStamp]
) WITH FILLFACTOR=66
*/

IF @SpecifyOnRoomTypeSegPos = 1
BEGIN
--print 'her 1'
	CREATE TABLE #ROOMBOOKINGSTATUS (
		[DateStamp] [char] (8) COLLATE DATABASE_DEFAULT NOT NULL ,
		[RoomTypeNumber] [int] NOT NULL ,
		[SegmentNumber] [int] NOT NULL ,
		[PointOfSaleNumber] [int] NOT NULL ,
		[HotelNumber] [int] NOT NULL ,
		[SoldRooms] [smallint] NULL ,
		[Adults] [smallint] NULL ,
		[Children1] [smallint] NULL ,
		[Children2] [smallint] NULL ,
		[NumberOfConfirmed] [smallint] NULL ,
		[NumberOfProvisionals] [smallint] NULL ,
		[NumberOfGuaranteed] [smallint] NULL ,
		[NumberOfTentative] [smallint] NULL ,
		[NumberOfWaitinglists] [smallint] NULL ,
		[NumberOfDayrooms] [smallint] NULL ,
		[FreeRoomsAllotment] [smallint] NULL ,
		[TotalRoomsAllotment] [smallint] NULL ,
		[PaxAllotment] [smallint] NULL,
		[NumberOfRoomsSoldToday] [smallint] NULL,
		[NumberOfOutOfOrder] [smallint] NULL,
		[SoldPrice] [MONEY] NULL
--		[NumberOfOutOfHouseDayRooms] [smallint] NULL
--  		ON [PRIMARY]
		)
/*
		CREATE UNIQUE INDEX [#PK_ROOMBOOKINGSTATUS] ON #ROOMBOOKINGSTATUS(
			[DateStamp],

			[RoomTypeNumber],
			[SegmentNumber],
			[PointOfSaleNumber],
			[HotelNumber]
		) WITH FILLFACTOR=66
*/
END
ELSE
BEGIN
--print 'her 1'
	CREATE TABLE #ROOMBOOKINGSTATUS2 (
		[DateStamp] [char] (8) COLLATE DATABASE_DEFAULT NOT NULL ,
		[RoomTypeNumber] [int] NOT NULL ,
		[HotelNumber] [int] NOT NULL ,
		[SoldRooms] [smallint] NULL ,
		[Adults] [smallint] NULL ,
		[Children1] [smallint] NULL ,
		[Children2] [smallint] NULL ,
		[NumberOfConfirmed] [smallint] NULL ,
		[NumberOfProvisionals] [smallint] NULL ,
		[NumberOfGuaranteed] [smallint] NULL ,
		[NumberOfTentative] [smallint] NULL ,
		[NumberOfWaitinglists] [smallint] NULL ,
		[NumberOfDayrooms] [smallint] NULL ,
		[FreeRoomsAllotment] [smallint] NULL ,
		[TotalRoomsAllotment] [smallint] NULL ,
		[PaxAllotment] [smallint] NULL,
		[NumberOfRoomsSoldToday] [smallint] NULL,
		[NumberOfOutOfOrder] [smallint] NULL,
		[SoldPrice] [MONEY] NULL
--		[NumberOfOutOfHouseDayRooms] [smallint] NULL
--  		ON [PRIMARY]
		)
/*
		CREATE UNIQUE INDEX [#PK_ROOMBOOKINGSTATUS2] ON #ROOMBOOKINGSTATUS2(
			[DateStamp],
			[RoomTypeNumber],
			[HotelNumber]
		) WITH FILLFACTOR=66
*/
END





