IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[SegmentSectorXTAB]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN

	CREATE TABLE [dbo].[SegmentSectorXTAB](
		[FK_Segmentnumber] [smallint] NOT NULL,
		[FK_SectorNumber] [int] NOT NULL,
	 CONSTRAINT [PK_SegmentSectorXTAB] PRIMARY KEY CLUSTERED 
	(
		[FK_Segmentnumber] ASC,
		[FK_SectorNumber] ASC
	)
	) ON [PRIMARY]

	ALTER TABLE [dbo].[SegmentSectorXTAB]  WITH CHECK ADD  CONSTRAINT [FK_SegmentSectorXTAB_Sectors] FOREIGN KEY([FK_SectorNumber])
	REFERENCES [dbo].[Sectors] ([SectorNumber])

	ALTER TABLE [dbo].[SegmentSectorXTAB] CHECK CONSTRAINT [FK_SegmentSectorXTAB_Sectors]

	ALTER TABLE [dbo].[SegmentSectorXTAB]  WITH CHECK ADD  CONSTRAINT [FK_SegmentSectorXTAB_SegmentSectorXTAB] FOREIGN KEY([FK_Segmentnumber])
	REFERENCES [dbo].[Segments] ([Number])

	ALTER TABLE [dbo].[SegmentSectorXTAB] CHECK CONSTRAINT [FK_SegmentSectorXTAB_SegmentSectorXTAB]
END


