CREATE TABLE [dbo].[XmlQuoteLink]
(
[XmlQuoteLinkID] [int] NOT NULL IDENTITY(1, 1),
[QuoteHeaderFID] [int] NOT NULL,
[XmlSystemFID] [int] NOT NULL,
[OrdersFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlQuoteLink] ADD CONSTRAINT [PK_XmlQuoteLink] PRIMARY KEY CLUSTERED ([XmlQuoteLinkID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlQuoteLink] ADD CONSTRAINT [IX_XmlQuoteLink_System_Orders] UNIQUE NONCLUSTERED ([OrdersFID], [XmlSystemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlQuoteLink] ADD CONSTRAINT [FK_XmlQuoteLink_Orders] FOREIGN KEY ([OrdersFID]) REFERENCES [dbo].[Orders] ([PriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[XmlQuoteLink] ADD CONSTRAINT [FK_XmlQuoteLink_QuoteHeader] FOREIGN KEY ([QuoteHeaderFID]) REFERENCES [dbo].[QuoteHeader] ([QuoteHeaderID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[XmlQuoteLink] ADD CONSTRAINT [FK_XmlQuoteLink_XmlSystem] FOREIGN KEY ([XmlSystemFID]) REFERENCES [dbo].[XmlSystem] ([XmlSystemID])
GO
GRANT SELECT ON [dbo].[XmlQuoteLink] TO [MssExec]
GRANT INSERT ON [dbo].[XmlQuoteLink] TO [MssExec]
GRANT DELETE ON [dbo].[XmlQuoteLink] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlQuoteLink] TO [MssExec]
GO