if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ConferenceRoomsCategoryXtab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

CREATE TABLE [dbo].[ConferenceRoomsCategoryXtab](
	[FK_ConferenceRoomNumber] [int] NOT NULL,
	[FK_CategoryNumber] [int] NOT NULL
) ON [PRIMARY]

GO

IF NOT EXISTS (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_ConferenceRoomsCategoryXtab_Category')
  ALTER TABLE [dbo].[ConferenceRoomsCategoryXtab]  WITH CHECK ADD  CONSTRAINT [FK_ConferenceRoomsCategoryXtab_Category] FOREIGN KEY([FK_CategoryNumber])
  REFERENCES [dbo].[Category] ([CategoryNumber])
GO

IF EXISTS (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_ConferenceRoomsCategoryXtab_Category')
  ALTER TABLE [dbo].[ConferenceRoomsCategoryXtab] CHECK CONSTRAINT [FK_ConferenceRoomsCategoryXtab_Category]
GO

IF NOT EXISTS (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_ConferenceRoomsCategoryXtab_CONFERENCEROOMS')
  ALTER TABLE [dbo].[ConferenceRoomsCategoryXtab]  WITH CHECK ADD  CONSTRAINT [FK_ConferenceRoomsCategoryXtab_CONFERENCEROOMS] FOREIGN KEY([FK_ConferenceRoomNumber])
  REFERENCES [dbo].[CONFERENCEROOMS] ([ConferenceRoomNumber])
GO

IF EXISTS (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_ConferenceRoomsCategoryXtab_CONFERENCEROOMS')
  ALTER TABLE [dbo].[ConferenceRoomsCategoryXtab] CHECK CONSTRAINT [FK_ConferenceRoomsCategoryXtab_CONFERENCEROOMS]
GO


