[dbo].[OrderInstructions]
CREATE TABLE [dbo].[OrderInstructions]
(
[OrderInstructionsID] [int] NOT NULL IDENTITY(1, 1),
[OrderInstructionTypeFID] [int] NOT NULL,
[OrderFID] [int] NOT NULL,
[SysUserFID] [int] NOT NULL,
[Date] [datetime] NOT NULL,
[Instruction] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OriginDestination] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderInstructions] ADD CONSTRAINT [PK_OrderInstructions] PRIMARY KEY CLUSTERED ([OrderInstructionsID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderInstructions] ADD CONSTRAINT [IX_OrderInstructions_OrderInstructionType_Order] UNIQUE NONCLUSTERED ([OrderInstructionTypeFID], [OrderFID], [OriginDestination]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderInstructions_OrderFID] ON [dbo].[OrderInstructions] ([OrderFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderInstructions_SysUserFID] ON [dbo].[OrderInstructions] ([SysUserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderInstructions] ADD CONSTRAINT [FK_OrderInstructions_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[OrderInstructions] ADD CONSTRAINT [FK_OrderInstructions_OrderInstructionTypes] FOREIGN KEY ([OrderInstructionTypeFID]) REFERENCES [dbo].[OrderInstructionTypes] ([OrderInstructionTypeID])
GO
ALTER TABLE [dbo].[OrderInstructions] ADD CONSTRAINT [FK_OrderInstructions_Sysuser] FOREIGN KEY ([SysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[OrderInstructions] TO [MssExec]
GRANT INSERT ON [dbo].[OrderInstructions] TO [MssExec]
GRANT DELETE ON [dbo].[OrderInstructions] TO [MssExec]
GRANT UPDATE ON [dbo].[OrderInstructions] TO [MssExec]
GO