
[dbo].[CustomerInvoiceReport]
CREATE TABLE [dbo].[CustomerInvoiceReport]
(
[CustomerInvoiceReportID] [int] NOT NULL IDENTITY(1, 1),
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ReportFID] [int] NOT NULL,
[AccountingCustomerFid] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CustomerInvoiceReport] ADD CONSTRAINT [PK_CustomerInvoiceReport] PRIMARY KEY CLUSTERED ([CustomerInvoiceReportID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CustomerInvoiceReport_AccountingCustomerFid] ON [dbo].[CustomerInvoiceReport] ([AccountingCustomerFid]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerInvoiceReport_CustomerNumber] ON [dbo].[CustomerInvoiceReport] ([CustomerNumber]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CustomerInvoiceReport] ADD CONSTRAINT [FK_CustomerInvoiceReport_AccountingCustomer] FOREIGN KEY ([AccountingCustomerFid]) REFERENCES [dbo].[AccountingCustomer] ([AccountingCustomerId])
GO
ALTER TABLE [dbo].[CustomerInvoiceReport] ADD CONSTRAINT [FK_CustomerInvoiceReport_ReportFID] FOREIGN KEY ([ReportFID]) REFERENCES [dbo].[Reports] ([Prikey])
GO
GRANT SELECT ON [dbo].[CustomerInvoiceReport] TO [MssExec]
GRANT INSERT ON [dbo].[CustomerInvoiceReport] TO [MssExec]
GRANT DELETE ON [dbo].[CustomerInvoiceReport] TO [MssExec]
GRANT UPDATE ON [dbo].[CustomerInvoiceReport] TO [MssExec]
GO