[dbo].[VanlineStatementHeader]
CREATE TABLE [dbo].[VanlineStatementHeader]
(
[VanlineStatementHeaderID] [int] NOT NULL IDENTITY(1, 1),
[VanlineGroupExternalCode] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[VanlineGroupFID] [int] NULL,
[AgentNumber] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[AgentFID] [int] NULL,
[StatementDate] [datetime] NOT NULL,
[StatementYear] [int] NOT NULL,
[StatementNumber] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[LastReceivedDate] [datetime] NOT NULL,
[StatementDescription] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsCRBatch] [bit] NULL,
[IsVanLineStatement] [bit] NULL,
[AutoApply] [bit] NULL,
[Importable] [bit] NOT NULL,
[ImportBegan] [bit] NOT NULL CONSTRAINT [DF_VanlineStatementHeader_ImportBegan] DEFAULT ((0)),
[ImportingBy] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[VanlineStatementHeader] ADD CONSTRAINT [PK_VanlineStatementHeader] PRIMARY KEY CLUSTERED ([VanlineStatementHeaderID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_VanlineStatementHeader_AgentDate] ON [dbo].[VanlineStatementHeader] ([AgentNumber], [StatementDate], [VanlineGroupExternalCode]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_VanlineStatementHeader_AgentYearNumber] ON [dbo].[VanlineStatementHeader] ([AgentNumber], [StatementYear], [StatementNumber], [VanlineGroupExternalCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[VanlineStatementHeader] ADD CONSTRAINT [FK_VanlineStatementHeader_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey])
GO
ALTER TABLE [dbo].[VanlineStatementHeader] ADD CONSTRAINT [FK_VanlineStatementHeader_VanlineGroup] FOREIGN KEY ([VanlineGroupFID]) REFERENCES [dbo].[VanlineGroup] ([VanlineGroupID])
GO
GRANT SELECT ON [dbo].[VanlineStatementHeader] TO [MssExec]
GRANT INSERT ON [dbo].[VanlineStatementHeader] TO [MssExec]
GRANT DELETE ON [dbo].[VanlineStatementHeader] TO [MssExec]
GRANT UPDATE ON [dbo].[VanlineStatementHeader] TO [MssExec]
GO