[dbo].[RevenueRatingImportedInvoiceDetail]
CREATE TABLE [dbo].[RevenueRatingImportedInvoiceDetail]
(
[RevenueRatingImportedInvoiceDetailID] [int] NOT NULL IDENTITY(1, 1),
[RevenueRatingImportedHeaderFID] [int] NOT NULL,
[AgentFID] [int] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GrossAmount] [decimal] (12, 4) NULL,
[DiscountPct] [decimal] (12, 4) NULL,
[DistributionCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PrintDescription] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Quantity2] [decimal] (12, 4) NULL,
[Quantity] [decimal] (12, 4) NULL,
[Rate] [decimal] (12, 4) NULL,
[RateTypeFID] [int] NULL,
[ImportDateTime] [datetime] NULL,
[OrdersFID] [int] NULL,
[CarrierBillingMinorFID] [int] NULL,
[CarrierBillingMajorFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RevenueRatingImportedInvoiceDetail] ADD CONSTRAINT [PK_RevenueRatingImportedInvoiceDetail] PRIMARY KEY NONCLUSTERED ([RevenueRatingImportedInvoiceDetailID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RevenueRatingImportedInvoiceDetail_CarrierBillingMinor] ON [dbo].[RevenueRatingImportedInvoiceDetail] ([CarrierBillingMinorFID]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_RevenueRatingImportedInvoiceDetailFID] ON [dbo].[RevenueRatingImportedInvoiceDetail] ([RevenueRatingImportedHeaderFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RevenueRatingImportedInvoiceDetail] ADD CONSTRAINT [FK_RevenueRatingImportedInvoiceDetail_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey])
GO
ALTER TABLE [dbo].[RevenueRatingImportedInvoiceDetail] ADD CONSTRAINT [FK_RevenueRatingImportedInvoiceDetail_RateType] FOREIGN KEY ([RateTypeFID]) REFERENCES [dbo].[RateTypes] ([RTypePriKey]) ON DELETE SET NULL
GO
ALTER TABLE [dbo].[RevenueRatingImportedInvoiceDetail] ADD CONSTRAINT [FK_RevenueRatingImportedInvoiceDetail_RevenueRatingImportedHeader] FOREIGN KEY ([RevenueRatingImportedHeaderFID]) REFERENCES [dbo].[RevenueRatingImportedHeader] ([RevenueRatingImportedHeaderID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[RevenueRatingImportedInvoiceDetail] TO [MssExec]
GRANT INSERT ON [dbo].[RevenueRatingImportedInvoiceDetail] TO [MssExec]
GRANT DELETE ON [dbo].[RevenueRatingImportedInvoiceDetail] TO [MssExec]
GRANT UPDATE ON [dbo].[RevenueRatingImportedInvoiceDetail] TO [MssExec]
GO