CREATE TABLE [dbo].[XmlOrderLink]
(
[XmlOrderLinkID] [int] NOT NULL IDENTITY(1, 1),
[OrderFID] [int] NOT NULL,
[XmlSystemFID] [int] NOT NULL,
[ExternalKey] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[SecondaryExternalKey] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderLink] ADD CONSTRAINT [PK_XmlOrderLink] PRIMARY KEY CLUSTERED ([XmlOrderLinkID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderLink] ADD CONSTRAINT [IX_Unique_XmlOrderLink_System_Order] UNIQUE NONCLUSTERED ([XmlSystemFID], [OrderFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XmlOrderLink_Order_System] ON [dbo].[XmlOrderLink] ([OrderFID], [XmlSystemFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XmlOrderLink_System_ExternalKey] ON [dbo].[XmlOrderLink] ([XmlSystemFID], [ExternalKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderLink] ADD CONSTRAINT [FK_XmlOrderLink_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[XmlOrderLink] ADD CONSTRAINT [FK_XmlOrderLink_XmlSystem] FOREIGN KEY ([XmlSystemFID]) REFERENCES [dbo].[XmlSystem] ([XmlSystemID])
GO
GRANT SELECT ON [dbo].[XmlOrderLink] TO [MssExec]
GRANT INSERT ON [dbo].[XmlOrderLink] TO [MssExec]
GRANT DELETE ON [dbo].[XmlOrderLink] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlOrderLink] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'The primary key for the xml system.', 'SCHEMA', N'dbo', 'TABLE', N'XmlOrderLink', 'COLUMN', N'ExternalKey'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Foreign key to an order.', 'SCHEMA', N'dbo', 'TABLE', N'XmlOrderLink', 'COLUMN', N'OrderFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The primary key.', 'SCHEMA', N'dbo', 'TABLE', N'XmlOrderLink', 'COLUMN', N'XmlOrderLinkID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Foreign key to an xml system.', 'SCHEMA', N'dbo', 'TABLE', N'XmlOrderLink', 'COLUMN', N'XmlSystemFID'
GO