[dbo].[StorageInvHistCrBatch]
CREATE TABLE [dbo].[StorageInvHistCrBatch]
(
[StorageInvHistCrBatchID] [int] NOT NULL IDENTITY(1, 1),
[StorageInvoiceHistoricalFID] [int] NOT NULL,
[BranchFID] [int] NOT NULL,
[StorageTypeFID] [int] NOT NULL,
[StatementHeaderFID] [int] NOT NULL,
[ProviderTypeFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [PK_StorageInvHistCrBatch] PRIMARY KEY NONCLUSTERED ([StorageInvHistCrBatchID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_StorageInvHistCrBatch_StatementHeader] ON [dbo].[StorageInvHistCrBatch] ([StatementHeaderFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StorageInvHistCrBatch_StgInvHist_Branch_StorageType] ON [dbo].[StorageInvHistCrBatch] ([StorageInvoiceHistoricalFID], [BranchFID], [StorageTypeFID], [ProviderTypeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [FK_StorageInvHistCrBatch_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [FK_StorageInvHistCrBatch_ProviderType] FOREIGN KEY ([ProviderTypeFID]) REFERENCES [dbo].[PlasticProviderType] ([ProviderTypeID])
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [FK_StorageInvHistCrBatch_StatementHeader] FOREIGN KEY ([StatementHeaderFID]) REFERENCES [dbo].[StatementHeader] ([SHPriKey])
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [FK_StorageInvHistCrBatch_StorageInvoiceHistorical] FOREIGN KEY ([StorageInvoiceHistoricalFID]) REFERENCES [dbo].[StorageInvoiceHistorical] ([StorageInvoiceHistoricalID])
GO
ALTER TABLE [dbo].[StorageInvHistCrBatch] ADD CONSTRAINT [FK_StorageInvHistCrBatch_StorageType] FOREIGN KEY ([StorageTypeFID]) REFERENCES [dbo].[StorageType] ([StorageTypePriKey])
GO
GRANT SELECT ON [dbo].[StorageInvHistCrBatch] TO [MssExec]
GRANT INSERT ON [dbo].[StorageInvHistCrBatch] TO [MssExec]
GRANT DELETE ON [dbo].[StorageInvHistCrBatch] TO [MssExec]
GRANT UPDATE ON [dbo].[StorageInvHistCrBatch] TO [MssExec]
GO