/* Run this script on SQL Server 2008 or later. There may be flaws if running on earlier versions of SQL Server. */ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Company2Client]') AND type in (N'U')) DROP TABLE [dbo].[Company2Client] GO CREATE TABLE [dbo].[Company2Client] ( [Id] [uniqueidentifier] NOT NULL, [CompanyId] [uniqueidentifier] NOT NULL, [ClientId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Company2Client] PRIMARY KEY CLUSTERED ([Id]) ) ON [PRIMARY] GO ALTER TABLE [dbo].[Company2Client] ADD CONSTRAINT [FK_Company2Client_ClientId] FOREIGN KEY ([ClientId]) REFERENCES [dbo].[Client] ([Id]) GO ALTER TABLE [dbo].[Company2Client] ADD CONSTRAINT [FK_Company2Client_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Company] ([Id]) GO