CREATE TABLE [dbo].[ThirdParty]
(
[TPPriKey] [int] NOT NULL IDENTITY(1, 1),
[BMinPriKey] [int] NULL,
[BMinDistPriKey] [int] NULL,
[VendorID] [char] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[PayableAmount] [money] NULL,
[InvoiceNumber] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PONumber] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ANPriKey] [int] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DocDate] [datetime] NULL,
[JournalDate] [datetime] NULL,
[PostedDate] [datetime] NULL,
[PostedBy] [int] NULL,
[ApplyToDoc] [int] NULL,
[InvoiceDate] [datetime] NULL,
[1099Flag] [bit] NOT NULL CONSTRAINT [DF_ThirdParty_1099Flag] DEFAULT ((0)),
[OnHoldFlag] [bit] NOT NULL CONSTRAINT [DF_ThirdParty_OnHoldFlag] DEFAULT ((0)),
[DocumentNumber] [varchar] (21) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OriginalInvoiceNumber] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ThirdParty] ADD CONSTRAINT [PK_ThirdParty] PRIMARY KEY NONCLUSTERED ([TPPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ThirdParty_ANPriKey] ON [dbo].[ThirdParty] ([ANPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ThirdParty_BMinDistPriKey] ON [dbo].[ThirdParty] ([BMinDistPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_ThirdParty_BMinPriKey] ON [dbo].[ThirdParty] ([BMinPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ThirdParty_DocumentNumber] ON [dbo].[ThirdParty] ([DocumentNumber]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ThirdParty_PostedBy] ON [dbo].[ThirdParty] ([PostedBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ThirdParty_VendorID_InvoiceNumber] ON [dbo].[ThirdParty] ([VendorID], [InvoiceNumber]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ThirdParty] ADD CONSTRAINT [FK_ThirdParty_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[ThirdParty] ADD CONSTRAINT [FK_ThirdParty_BillingMinorDist] FOREIGN KEY ([BMinDistPriKey]) REFERENCES [dbo].[BillingMinorDist] ([BMinDistPriKey])
GO
ALTER TABLE [dbo].[ThirdParty] ADD CONSTRAINT [FK_ThirdParty_BillingMinorItem] FOREIGN KEY ([BMinPriKey]) REFERENCES [dbo].[BillingMinorItem] ([BMinPriKey])
GO
ALTER TABLE [dbo].[ThirdParty] ADD CONSTRAINT [FK_ThirdParty_Sysuser] FOREIGN KEY ([PostedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[ThirdParty] TO [MssExec]
GRANT INSERT ON [dbo].[ThirdParty] TO [MssExec]
GRANT DELETE ON [dbo].[ThirdParty] TO [MssExec]
GRANT UPDATE ON [dbo].[ThirdParty] TO [MssExec]
GO