CREATE TABLE [dbo].[QuoteHeader]
(
[QuoteHeaderID] [int] NOT NULL IDENTITY(1, 1),
[OrdersFID] [int] NOT NULL,
[CreatedDate] [datetime] NULL,
[CreatedBySysuserFID] [int] NULL,
[QuoteStatusFID] [int] NOT NULL,
[FirstTimeAccepted] [bit] NOT NULL CONSTRAINT [DF_QuoteHeader_FirstTimeAccepted] DEFAULT ((0)),
[VanLineLinked] [bit] NOT NULL CONSTRAINT [DF_QuoteHeader_VanLineLinked] DEFAULT ((0)),
[OrderContactFID] [int] NULL,
[Description] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuoteHeader] ADD CONSTRAINT [CK_QuoteHeader_OnlyOneVanLineLinked] CHECK (((1)=[dbo].[IsOnlyOneVanLineLinked]([QuoteHeaderID],[OrdersFID],[VanLineLinked])))
GO
ALTER TABLE [dbo].[QuoteHeader] ADD CONSTRAINT [PK_QuoteHeader] PRIMARY KEY NONCLUSTERED ([QuoteHeaderID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_QuoteHeader_Orders] ON [dbo].[QuoteHeader] ([OrdersFID], [QuoteHeaderID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuoteHeader] ADD CONSTRAINT [FK_QuoteHeader_OrderContact] FOREIGN KEY ([OrderContactFID]) REFERENCES [dbo].[OrderContacts] ([OrderContactID])
GO
ALTER TABLE [dbo].[QuoteHeader] ADD CONSTRAINT [FK_QuoteHeader_QuoteStatus] FOREIGN KEY ([QuoteStatusFID]) REFERENCES [dbo].[QuoteStatus] ([QuoteStatusID])
GO
GRANT SELECT ON [dbo].[QuoteHeader] TO [MssExec]
GRANT INSERT ON [dbo].[QuoteHeader] TO [MssExec]
GRANT DELETE ON [dbo].[QuoteHeader] TO [MssExec]
GRANT UPDATE ON [dbo].[QuoteHeader] TO [MssExec]
GO