[dbo].[OutgoingEmailStatus]
CREATE TABLE [dbo].[OutgoingEmailStatus]
(
[OutgoingEmailStatusId] [int] NOT NULL IDENTITY(1, 1),
[OutgoingEmailFID] [int] NOT NULL,
[LastActivity] [datetimeoffset] NOT NULL,
[Succeeded] [bit] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailStatus] ADD CONSTRAINT [PK_OutgoingEmailStatus] PRIMARY KEY NONCLUSTERED ([OutgoingEmailStatusId]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OutgoingEmailStatus_LastActivity] ON [dbo].[OutgoingEmailStatus] ([LastActivity]) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [IX_OutgoingEmailStatus_OutgoingEmailFID] ON [dbo].[OutgoingEmailStatus] ([OutgoingEmailFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OutgoingEmailStatus] ADD CONSTRAINT [FK_OutgoingEmailStatus_OutgoingEmail] FOREIGN KEY ([OutgoingEmailFID]) REFERENCES [dbo].[OutgoingEmail] ([OutgoingEmailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[OutgoingEmailStatus] TO [MssExec]
GRANT INSERT ON [dbo].[OutgoingEmailStatus] TO [MssExec]
GRANT DELETE ON [dbo].[OutgoingEmailStatus] TO [MssExec]
GRANT UPDATE ON [dbo].[OutgoingEmailStatus] TO [MssExec]
GO