[dbo].[OutgoingEmailDocumentAttachment]
CREATE TABLE [dbo].[OutgoingEmailDocumentAttachment]
(
[OutgoingEmailDocumentAttachmentId] [int] NOT NULL IDENTITY(1, 1),
[OutgoingEmailFID] [int] NOT NULL,
[MssDocumentFID] [int] NOT NULL,
[AttachmentOrder] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailDocumentAttachment] ADD CONSTRAINT [PK_OutgoingEmailDocumentAttachment] PRIMARY KEY NONCLUSTERED ([OutgoingEmailDocumentAttachmentId]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_OutgoingEmailDocumentAttachment_OutgoingEmailFID_AttachmentOrder] ON [dbo].[OutgoingEmailDocumentAttachment] ([OutgoingEmailFID], [AttachmentOrder]) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [IX_OutgoingEmailDocumentAttachment_OutgoingEmailFID_MssDocumentFID] ON [dbo].[OutgoingEmailDocumentAttachment] ([OutgoingEmailFID], [MssDocumentFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailDocumentAttachment] ADD CONSTRAINT [FK_OutgoingEmailDocumentAttachment_MssDocument] FOREIGN KEY ([MssDocumentFID]) REFERENCES [dbo].[MSSDocument] ([MSSDocumentID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[OutgoingEmailDocumentAttachment] ADD CONSTRAINT [FK_OutgoingEmailDocumentAttachment_OutgoingEmail] FOREIGN KEY ([OutgoingEmailFID]) REFERENCES [dbo].[OutgoingEmail] ([OutgoingEmailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[OutgoingEmailDocumentAttachment] TO [MssExec]
GRANT INSERT ON [dbo].[OutgoingEmailDocumentAttachment] TO [MssExec]
GRANT DELETE ON [dbo].[OutgoingEmailDocumentAttachment] TO [MssExec]
GRANT UPDATE ON [dbo].[OutgoingEmailDocumentAttachment] TO [MssExec]
GO