[dbo].[XmlOrderEmailTypeMap]
CREATE TABLE [dbo].[XmlOrderEmailTypeMap]
(
[XmlOrderEmailTypeMapID] [int] NOT NULL IDENTITY(1, 1),
[OrderEmailTypeFID] [int] NOT NULL,
[XmlInterfaceFID] [int] NOT NULL,
[ExternalCode] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderEmailTypeMap] ADD CONSTRAINT [PK_XmlOrderEmailTypeMap] PRIMARY KEY NONCLUSTERED ([XmlOrderEmailTypeMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderEmailTypeMap] ADD CONSTRAINT [IX_XmlOrderEmailTypeMap_OrderEmailType_XMLInterface] UNIQUE NONCLUSTERED ([OrderEmailTypeFID], [XmlInterfaceFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderEmailTypeMap] ADD CONSTRAINT [IX_XmlOrderEmailTypeMap_XMLInterface_ExternalCode] UNIQUE NONCLUSTERED ([XmlInterfaceFID], [ExternalCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlOrderEmailTypeMap] ADD CONSTRAINT [FK_XmlOrderEmailTypeMap_OrderEmailType] FOREIGN KEY ([OrderEmailTypeFID]) REFERENCES [dbo].[OrderEmailType] ([OrderEmailTypeID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[XmlOrderEmailTypeMap] ADD CONSTRAINT [FK_XmlOrderEmailTypeMap_XmlInterface] FOREIGN KEY ([XmlInterfaceFID]) REFERENCES [dbo].[XmlInterface] ([XmlInterfaceID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[XmlOrderEmailTypeMap] TO [MssExec]
GRANT INSERT ON [dbo].[XmlOrderEmailTypeMap] TO [MssExec]
GRANT DELETE ON [dbo].[XmlOrderEmailTypeMap] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlOrderEmailTypeMap] TO [MssExec]
GO