CREATE TABLE [dbo].[OrderNoteDetail]
(
[OrderNoteDetailID] [int] NOT NULL IDENTITY(1, 1),
[OrderNoteHeaderFID] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[CreatedByFID] [int] NOT NULL,
[NoteBody] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LocalServiceFID] [int] NULL,
[PublicFlag] [bit] NOT NULL,
[NoteXml] [xml] NULL,
[LineNumber] [int] NULL,
[SendToVanline] [bit] NULL,
[Initials] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[VanlinePublicFlag] [bit] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderNoteDetail] ADD CONSTRAINT [PK_OrderNoteDetail] PRIMARY KEY CLUSTERED ([OrderNoteDetailID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderNoteDetail_CreatedByFID] ON [dbo].[OrderNoteDetail] ([CreatedByFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderNoteDetail_LocalServiceFID] ON [dbo].[OrderNoteDetail] ([LocalServiceFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OrderNoteDetail_OrderNoteHeaderFID] ON [dbo].[OrderNoteDetail] ([OrderNoteHeaderFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderNoteDetail] ADD CONSTRAINT [FK_OrderNoteDetail_Sysuser] FOREIGN KEY ([CreatedByFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[OrderNoteDetail] ADD CONSTRAINT [FK_OrderNoteDetail_LocServ] FOREIGN KEY ([LocalServiceFID]) REFERENCES [dbo].[LocServ] ([PriKey])
GO
ALTER TABLE [dbo].[OrderNoteDetail] ADD CONSTRAINT [FK_OrderNoteDetail_OrderNoteHeader] FOREIGN KEY ([OrderNoteHeaderFID]) REFERENCES [dbo].[OrderNoteHeader] ([OrderNoteHeaderID])
GO
GRANT SELECT ON [dbo].[OrderNoteDetail] TO [MssExec]
GRANT INSERT ON [dbo].[OrderNoteDetail] TO [MssExec]
GRANT DELETE ON [dbo].[OrderNoteDetail] TO [MssExec]
GRANT UPDATE ON [dbo].[OrderNoteDetail] TO [MssExec]
GO