[dbo].[OutgoingEmailFileAttachment]
CREATE TABLE [dbo].[OutgoingEmailFileAttachment]
(
[OutgoingEmailFileAttachmentId] [int] NOT NULL IDENTITY(1, 1),
[OutgoingEmailFID] [int] NOT NULL,
[Content] [varbinary] (max) NOT NULL,
[FileName] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[AttachmentOrder] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailFileAttachment] ADD CONSTRAINT [PK_OutgoingEmailFileAttachment] PRIMARY KEY NONCLUSTERED ([OutgoingEmailFileAttachmentId]) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [IX_OutgoingEmailFileAttachment_OutgoingEmailFID_AttachmentOrder] ON [dbo].[OutgoingEmailFileAttachment] ([OutgoingEmailFID], [AttachmentOrder]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailFileAttachment] ADD CONSTRAINT [FK_OutgoingEmailFileAttachment_OutgoingEmail] FOREIGN KEY ([OutgoingEmailFID]) REFERENCES [dbo].[OutgoingEmail] ([OutgoingEmailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[OutgoingEmailFileAttachment] TO [MssExec]
GRANT INSERT ON [dbo].[OutgoingEmailFileAttachment] TO [MssExec]
GRANT DELETE ON [dbo].[OutgoingEmailFileAttachment] TO [MssExec]
GRANT UPDATE ON [dbo].[OutgoingEmailFileAttachment] TO [MssExec]
GO