[dbo].[XmlOrderAddressMap]
CREATE TABLE [dbo].[XmlOrderAddressMap]
(
[XmlOrderAddressMapID] [int] NOT NULL IDENTITY(1, 1),
[OrderFID] [int] NOT NULL,
[OrderAddressFID] [int] NOT NULL,
[XmlSystemFID] [int] NOT NULL,
[ExternalAddressNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ExternalTripNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ExternalMoveNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [PK_XmlOrderAddressMap] PRIMARY KEY CLUSTERED ([XmlOrderAddressMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [IX_XmlOrderAddressMap_OrderAddress_XmlSystem] UNIQUE NONCLUSTERED ([OrderAddressFID], [XmlSystemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [IX_XmlOrderAddressMap_Orders_XmlSystem_ExternalStopNumber] UNIQUE NONCLUSTERED ([OrderFID], [ExternalAddressNumber], [XmlSystemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [FK_XmlOrderAddressMap_OrderAddress] FOREIGN KEY ([OrderAddressFID]) REFERENCES [dbo].[OrderAddress] ([OrderAddressID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [FK_XmlOrderAddressMap_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[XmlOrderAddressMap] ADD CONSTRAINT [FK_XmlOrderAddressMap_XmlSystem] FOREIGN KEY ([XmlSystemFID]) REFERENCES [dbo].[XmlSystem] ([XmlSystemID])
GO
GRANT SELECT ON [dbo].[XmlOrderAddressMap] TO [MssExec]
GRANT INSERT ON [dbo].[XmlOrderAddressMap] TO [MssExec]
GRANT DELETE ON [dbo].[XmlOrderAddressMap] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlOrderAddressMap] TO [MssExec]
GO