CREATE TABLE [dbo].[StatementHeader]
(
[SHPriKey] [int] NOT NULL IDENTITY(1, 1),
[DateEntered] [datetime] NULL,
[StatementDesc] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DateDownload] [datetime] NULL,
[DownLoadedBy] [int] NULL,
[DatePosted] [datetime] NULL,
[PostedBy] [int] NULL,
[DateSplit] [datetime] NULL,
[Splitby] [int] NULL,
[JournalDate] [datetime] NULL,
[Amount] [money] NULL CONSTRAINT [DF_StatementHeader_Amount] DEFAULT (0),
[AgentPriKey] [int] NOT NULL,
[Status] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ANPriKey] [int] NULL,
[EnteredBy] [int] NULL,
[BranchPriKey] [int] NOT NULL,
[IsCRBatch] [smallint] NULL,
[FileName] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PMPostingAccountsPriKey] [int] NULL,
[IsManual] [smallint] NULL,
[IsClaimsBatch] [bit] NOT NULL CONSTRAINT [DF_StatementHeader_IsClaimsBatch] DEFAULT ((0)),
[IsVanLineStatement] [bit] NOT NULL CONSTRAINT [DF_StatementHeader_IsVanLineStatement] DEFAULT ((0)),
[IsPPBatch] [bit] NOT NULL CONSTRAINT [DF_StatementHeader_IsPPBatch] DEFAULT ((0)),
[IsGp2015Batch] [bit] NOT NULL CONSTRAINT [DF_StatementHeader_IsGp2015Batch] DEFAULT ((0)),
[ProviderTypeFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [PK_StatementHeader] PRIMARY KEY CLUSTERED ([SHPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_ANPriKey] ON [dbo].[StatementHeader] ([ANPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_BranchPriKey] ON [dbo].[StatementHeader] ([BranchPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_DownLoadedBy] ON [dbo].[StatementHeader] ([DownLoadedBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_EnteredBy] ON [dbo].[StatementHeader] ([EnteredBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_PostedBy] ON [dbo].[StatementHeader] ([PostedBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_ProviderType] ON [dbo].[StatementHeader] ([ProviderTypeFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_Splitby] ON [dbo].[StatementHeader] ([Splitby]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementHeader_Status] ON [dbo].[StatementHeader] ([Status]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_AGENT] FOREIGN KEY ([AgentPriKey]) REFERENCES [dbo].[Agent] ([AgentPriKey])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_Branch] FOREIGN KEY ([BranchPriKey]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_Sysuser] FOREIGN KEY ([DownLoadedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_Sysuser3] FOREIGN KEY ([EnteredBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_PMPostingAccounts] FOREIGN KEY ([PMPostingAccountsPriKey]) REFERENCES [dbo].[PMPostingAccounts] ([PMPostingAccountsPrikey])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_Sysuser1] FOREIGN KEY ([PostedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_PlasticProviderType] FOREIGN KEY ([ProviderTypeFID]) REFERENCES [dbo].[PlasticProviderType] ([ProviderTypeID])
GO
ALTER TABLE [dbo].[StatementHeader] ADD CONSTRAINT [FK_StatementHeader_Sysuser2] FOREIGN KEY ([Splitby]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[StatementHeader] TO [MssExec]
GRANT INSERT ON [dbo].[StatementHeader] TO [MssExec]
GRANT DELETE ON [dbo].[StatementHeader] TO [MssExec]
GRANT UPDATE ON [dbo].[StatementHeader] TO [MssExec]
GO