[dbo].[QuoteRevenueImport]
CREATE TABLE [dbo].[QuoteRevenueImport]
(
[QuoteRevenueImportID] [int] NOT NULL IDENTITY(1, 1),
[QuoteGroupFID] [int] NULL,
[QuoteDetailFID] [int] NULL,
[BillingMinorItemFID] [int] NULL,
[ImportedDate] [datetime] NOT NULL,
[ImportedBySysuserFID] [int] NOT NULL,
[AgentFID] [int] NOT NULL,
[BillingMajorItemFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [CK_QuoteRevenueImport_Quote] CHECK (([QuoteGroupFID] IS NULL AND [QuoteDetailFID] IS NOT NULL OR [QuoteGroupFID] IS NOT NULL AND [QuoteDetailFID] IS NULL))
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [PK_QuoteRevenueImport] PRIMARY KEY NONCLUSTERED ([QuoteRevenueImportID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_QuoteRevenueImport_BillingMajorItem] ON [dbo].[QuoteRevenueImport] ([BillingMajorItemFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_QuoteRevenueImport_BillingMinorItem] ON [dbo].[QuoteRevenueImport] ([BillingMinorItemFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_QuoteRevenueImport_ImportedBySysuserFID] ON [dbo].[QuoteRevenueImport] ([ImportedBySysuserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey])
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_BillingMajorItem] FOREIGN KEY ([BillingMajorItemFID]) REFERENCES [dbo].[BillingMajorItem] ([BMajPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_BillingMinorItem] FOREIGN KEY ([BillingMinorItemFID]) REFERENCES [dbo].[BillingMinorItem] ([BMinPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_ImportedBySysuser] FOREIGN KEY ([ImportedBySysuserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_QuoteDetail] FOREIGN KEY ([QuoteDetailFID]) REFERENCES [dbo].[QuoteDetail] ([QuoteDetailID])
GO
ALTER TABLE [dbo].[QuoteRevenueImport] ADD CONSTRAINT [FK_QuoteRevenueImport_QuoteGroup] FOREIGN KEY ([QuoteGroupFID]) REFERENCES [dbo].[QuoteGroup] ([QuoteGroupID])
GO
GRANT SELECT ON [dbo].[QuoteRevenueImport] TO [MssExec]
GRANT INSERT ON [dbo].[QuoteRevenueImport] TO [MssExec]
GRANT DELETE ON [dbo].[QuoteRevenueImport] TO [MssExec]
GRANT UPDATE ON [dbo].[QuoteRevenueImport] TO [MssExec]
GO