IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[OTAInvCountNotifLog]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[OTAInvCountNotifLog]
  (
    [DateStamp] [datetime] NOT NULL,
    [FKRateLevelChannelId] [int] NOT NULL,
    [FKRoomTypeNumber] [int] NOT NULL,
    [NumberOfRooms] [int] NOT NULL,
  CONSTRAINT [PK_OTAInvCountNotifLog] PRIMARY KEY CLUSTERED 
  (
    [DateStamp] ASC,
    [FKRateLevelChannelId] ASC,
    [FKRoomTypeNumber] ASC
  )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[OTAInvCountNotifLog]  WITH CHECK ADD  CONSTRAINT [FK_OTAInvCountNotifLog_RateLevelChannel] FOREIGN KEY([FKRateLevelChannelId])
  REFERENCES [dbo].[RateLevelChannel] ([RateLevelChannelId])

  ALTER TABLE [dbo].[OTAInvCountNotifLog] CHECK CONSTRAINT [FK_OTAInvCountNotifLog_RateLevelChannel]

  ALTER TABLE [dbo].[OTAInvCountNotifLog]  WITH CHECK ADD  CONSTRAINT [FK_OTAInvCountNotifLog_RoomTypes] FOREIGN KEY([FKRoomTypeNumber])
  REFERENCES [dbo].[RoomTypes] ([RoomTypeNumber])

  ALTER TABLE [dbo].[OTAInvCountNotifLog] CHECK CONSTRAINT [FK_OTAInvCountNotifLog_RoomTypes]
END