[dbo].[CustomerStatementRun]
CREATE TABLE [dbo].[CustomerStatementRun]
(
[CustomerStatementRunID] [int] NOT NULL IDENTITY(1, 1),
[CustomerStatementProfileFID] [int] NULL,
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CustomerName] [varchar] (65) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[StatementDate] [datetime] NOT NULL,
[SummarizeToDate] [datetime] NOT NULL,
[CutOffDate] [datetime] NOT NULL,
[Message] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[SuppressZeroBalancesFlag] [bit] NOT NULL,
[ExcludeCreditBalancesFlag] [bit] NOT NULL,
[PastDueBalancesFlag] [bit] NOT NULL,
[NonInvoicedItemsFlag] [bit] NOT NULL,
[ExcludeUnappliedPaymentsFlag] [bit] NOT NULL,
[ShowInvoiceDetailsFlag] [bit] NOT NULL,
[GeneratedDate] [datetime] NOT NULL,
[GeneratedBySysUserFID] [int] NOT NULL,
[GeneratedBySysUserBranchFID] [int] NOT NULL,
[HeaderBranchAddressFID] [int] NULL,
[HeaderVanlineAddressFID] [int] NULL,
[RemittanceBranchAddressFID] [int] NULL,
[RemittanceVanlineAddressFID] [int] NULL,
[CustomerStatementTitleFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [PK_CustomerStatementRun] PRIMARY KEY NONCLUSTERED ([CustomerStatementRunID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CustomerStatementRun_GeneratedBySysUserFID] ON [dbo].[CustomerStatementRun] ([GeneratedBySysUserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_CustomerStatementProfile] FOREIGN KEY ([CustomerStatementProfileFID]) REFERENCES [dbo].[CustomerStatementProfile] ([CustomerStatementProfileID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_CustomerStatementTitle] FOREIGN KEY ([CustomerStatementTitleFID]) REFERENCES [dbo].[CustomerStatementTitle] ([CustomerStatementTitleID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_Branch] FOREIGN KEY ([GeneratedBySysUserBranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_SysUser] FOREIGN KEY ([GeneratedBySysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_HeaderBranchAddress] FOREIGN KEY ([HeaderBranchAddressFID]) REFERENCES [dbo].[BranchAddress] ([BranchAddressID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_HeaderVanlineAddress] FOREIGN KEY ([HeaderVanlineAddressFID]) REFERENCES [dbo].[VanlineAddress] ([VanlineAddressID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_RemittanceBranchAddress] FOREIGN KEY ([RemittanceBranchAddressFID]) REFERENCES [dbo].[BranchAddress] ([BranchAddressID])
GO
ALTER TABLE [dbo].[CustomerStatementRun] ADD CONSTRAINT [FK_CustomerStatementRun_RemittanceVanlineAddress] FOREIGN KEY ([RemittanceVanlineAddressFID]) REFERENCES [dbo].[VanlineAddress] ([VanlineAddressID])
GO
GRANT SELECT ON [dbo].[CustomerStatementRun] TO [MssExec]
GRANT INSERT ON [dbo].[CustomerStatementRun] TO [MssExec]
GRANT DELETE ON [dbo].[CustomerStatementRun] TO [MssExec]
GRANT UPDATE ON [dbo].[CustomerStatementRun] TO [MssExec]
GO