[dbo].[FactoringPrepaymentItemCode]
CREATE TABLE [dbo].[FactoringPrepaymentItemCode]
(
[FactoringPrepaymentItemCodeID] [int] NOT NULL IDENTITY(1, 1),
[FactoringSetupFID] [int] NOT NULL,
[ItemCodeFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[FactoringPrepaymentItemCode] ADD CONSTRAINT [PK_FactoringPrepaymentItemCode] PRIMARY KEY NONCLUSTERED ([FactoringPrepaymentItemCodeID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[FactoringPrepaymentItemCode] ADD CONSTRAINT [IX_FactoringPrepaymentItemCode_Setup_ItemCode] UNIQUE NONCLUSTERED ([FactoringSetupFID], [ItemCodeFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_FactoringPrepaymentItemCode_ItemCode] ON [dbo].[FactoringPrepaymentItemCode] ([ItemCodeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[FactoringPrepaymentItemCode] ADD CONSTRAINT [FK_FactoringPrepaymentItemCode_FactoringSetupFID] FOREIGN KEY ([FactoringSetupFID]) REFERENCES [dbo].[FactoringSetup] ([FactoringSetupID])
GO
ALTER TABLE [dbo].[FactoringPrepaymentItemCode] ADD CONSTRAINT [FK_FactoringPrepaymentItemCode_ItemCodeFID] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
GRANT SELECT ON [dbo].[FactoringPrepaymentItemCode] TO [MssExec]
GRANT INSERT ON [dbo].[FactoringPrepaymentItemCode] TO [MssExec]
GRANT DELETE ON [dbo].[FactoringPrepaymentItemCode] TO [MssExec]
GRANT UPDATE ON [dbo].[FactoringPrepaymentItemCode] TO [MssExec]
GO