CREATE TABLE [dbo].[ICDetail]
(
[ICDPriKey] [int] NOT NULL IDENTITY(1, 1),
[ICPriKey] [int] NOT NULL,
[CommodityPriKey] [int] NULL,
[RevGLAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RevGLSubAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[AuthPriKey] [int] NULL,
[DTPriKey] [int] NULL,
[GLDefault] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MTGroupPriKey] [int] NULL,
[ServTypeGPriKey] [int] NULL,
[PayGLAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PayGLSubAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [CK_ICDetail_GLDefault] CHECK (((1)<>[dbo].[ICDetailDefaultExists]([ICPriKey],[ICDPriKey],[GLDefault])))
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [PK_ICDetail] PRIMARY KEY CLUSTERED ([ICDPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [IX_ICDetail_ICAuthCommMTGDT] UNIQUE NONCLUSTERED ([ICPriKey], [AuthPriKey], [CommodityPriKey], [MTGroupPriKey], [DTPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [FK_ICDetail_AUTHORITYTYPES] FOREIGN KEY ([AuthPriKey]) REFERENCES [dbo].[AuthorityTypes] ([AuthPriKey])
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [FK_ICDetail_CommType] FOREIGN KEY ([CommodityPriKey]) REFERENCES [dbo].[CommType] ([PriKey])
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [FK_ICDetail_DriverTypes] FOREIGN KEY ([DTPriKey]) REFERENCES [dbo].[DriverTypes] ([DTPriKey])
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [FK_ICDetail_ItemCode] FOREIGN KEY ([ICPriKey]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[ICDetail] ADD CONSTRAINT [FK_ICDetail_MoveTypeGroups] FOREIGN KEY ([MTGroupPriKey]) REFERENCES [dbo].[MoveTypeGroups] ([MTGroupPriKey])
GO
GRANT SELECT ON [dbo].[ICDetail] TO [MssExec]
GRANT INSERT ON [dbo].[ICDetail] TO [MssExec]
GRANT DELETE ON [dbo].[ICDetail] TO [MssExec]
GRANT UPDATE ON [dbo].[ICDetail] TO [MssExec]
GO