CREATE TABLE [dbo].[StorageInvoice]
(
[StorageInvoicePriKey] [int] NOT NULL IDENTITY(1, 1),
[IHPriKey] [int] NOT NULL,
[SessionID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[StorageFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StorageInvoice] ADD CONSTRAINT [PK_StorageInvoice] PRIMARY KEY NONCLUSTERED ([StorageInvoicePriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StorageInvoice] ADD CONSTRAINT [IX_StorageInvoice_IHPriKey] UNIQUE NONCLUSTERED ([IHPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StorageInvoice_SessionID] ON [dbo].[StorageInvoice] ([SessionID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StorageInvoice] ADD CONSTRAINT [FK_StorageInvoice_InvoicedHeader] FOREIGN KEY ([IHPriKey]) REFERENCES [dbo].[InvoicedHeader] ([IHPriKey])
GO
ALTER TABLE [dbo].[StorageInvoice] ADD CONSTRAINT [FK_StorageInvoice_StorageFID] FOREIGN KEY ([StorageFID]) REFERENCES [dbo].[Storage] ([StoragePriKey])
GO
GRANT SELECT ON [dbo].[StorageInvoice] TO [MssExec]
GRANT INSERT ON [dbo].[StorageInvoice] TO [MssExec]
GRANT DELETE ON [dbo].[StorageInvoice] TO [MssExec]
GRANT UPDATE ON [dbo].[StorageInvoice] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'Foreign key to an invoiced header.', 'SCHEMA', N'dbo', 'TABLE', N'StorageInvoice', 'COLUMN', N'IHPriKey'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The session of storage invoices.', 'SCHEMA', N'dbo', 'TABLE', N'StorageInvoice', 'COLUMN', N'SessionID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key.', 'SCHEMA', N'dbo', 'TABLE', N'StorageInvoice', 'COLUMN', N'StorageInvoicePriKey'
GO