[dbo].[OrderCompletedStatusHistory]
CREATE TABLE [dbo].[OrderCompletedStatusHistory]
(
[OrderCompletedStatusHistoryID] [bigint] NOT NULL IDENTITY(1, 1),
[OrderFID] [int] NOT NULL,
[ChangedBy] [int] NOT NULL,
[ChangedOn] [datetime] NOT NULL,
[ChangedIn] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderCompletedStatusHistory] ADD CONSTRAINT [PK_OrderCompletedStatusHistory] PRIMARY KEY CLUSTERED ([OrderFID], [OrderCompletedStatusHistoryID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderCompletedStatusHistory_ChangedOn_OrderFID] ON [dbo].[OrderCompletedStatusHistory] ([ChangedOn], [OrderFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderCompletedStatusHistory] ADD CONSTRAINT [FK_OrderCompletedStatusHistory_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[OrderCompletedStatusHistory] TO [MssExec]
GRANT INSERT ON [dbo].[OrderCompletedStatusHistory] TO [MssExec]
GRANT DELETE ON [dbo].[OrderCompletedStatusHistory] TO [MssExec]
GRANT UPDATE ON [dbo].[OrderCompletedStatusHistory] TO [MssExec]
GO