[dbo].[StatementDetailDist]
CREATE TABLE [dbo].[StatementDetailDist]
(
[SDDPriKey] [int] NOT NULL IDENTITY(1, 1),
[SDPriKey] [int] NULL,
[ANPriKey] [int] NULL,
[OrderControl] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Amount] [money] NULL CONSTRAINT [DF_StatementDetailDist_Amount] DEFAULT (0),
[Split] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BranchPriKey] [int] NOT NULL,
[OrdPriKey] [int] NULL,
[UnappliedCash] [smallint] NULL CONSTRAINT [DF_StatementDetailDist_UnappliedCash] DEFAULT (0),
[UnappliedAmount] [money] NULL CONSTRAINT [DF_StatementDetailDist_UnappliedAmount] DEFAULT (0),
[PaymentCodePriKey] [int] NULL,
[Balance] [money] NULL CONSTRAINT [DF_StatementDetailDist_Balance] DEFAULT (0),
[ApplyAmount] [money] NULL CONSTRAINT [DF_StatementDetailDist_ApplyAmount] DEFAULT (0),
[AmountRemaining] [money] NULL CONSTRAINT [DF_StatementDetailDist_AmountRemaining] DEFAULT (0),
[Adjustment] [smallint] NULL CONSTRAINT [DF_StatementDetailDist_Adjustment] DEFAULT (0),
[ApplyCheck] [int] NULL CONSTRAINT [DF_StatementDetailDist_ApplyCheck] DEFAULT (0),
[ContestCharge] [smallint] NULL CONSTRAINT [DF_StatementDetailDist_ContestCharge] DEFAULT (0),
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DivisionFID] [int] NULL,
[ClaimFID] [int] NULL,
[UnappliedBranchFID] [int] NULL,
[UnappliedDivisionFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [PK_StatementDetailDist] PRIMARY KEY CLUSTERED ([SDDPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_ANPriKey] ON [dbo].[StatementDetailDist] ([ANPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_BranchPriKey] ON [dbo].[StatementDetailDist] ([BranchPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_ContestCharge] ON [dbo].[StatementDetailDist] ([ContestCharge]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_OrdPriKey] ON [dbo].[StatementDetailDist] ([OrdPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_PaymentCodePriKey] ON [dbo].[StatementDetailDist] ([PaymentCodePriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_SDPriKey] ON [dbo].[StatementDetailDist] ([SDPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementDetailDist_SDPriKey_OrdPriKey] ON [dbo].[StatementDetailDist] ([SDPriKey], [OrdPriKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_Branch] FOREIGN KEY ([BranchPriKey]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_Claim] FOREIGN KEY ([ClaimFID]) REFERENCES [dbo].[Claim] ([ClaimID])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_Orders] FOREIGN KEY ([OrdPriKey]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_PaymentCode] FOREIGN KEY ([PaymentCodePriKey]) REFERENCES [dbo].[PaymentCode] ([PaymentCodePriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_StatementDetail] FOREIGN KEY ([SDPriKey]) REFERENCES [dbo].[StatementDetail] ([SDPriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_UnappliedBranch] FOREIGN KEY ([UnappliedBranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[StatementDetailDist] ADD CONSTRAINT [FK_StatementDetailDist_UnappliedDivision] FOREIGN KEY ([UnappliedDivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
GRANT SELECT ON [dbo].[StatementDetailDist] TO [MssExec]
GRANT INSERT ON [dbo].[StatementDetailDist] TO [MssExec]
GRANT DELETE ON [dbo].[StatementDetailDist] TO [MssExec]
GRANT UPDATE ON [dbo].[StatementDetailDist] TO [MssExec]
GO