CREATE TABLE [dbo].[GLARAP]
(
[GLAPriKey] [int] NOT NULL IDENTITY(1, 1),
[GLCPriKey] [int] NOT NULL,
[GLAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GLSubAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CommodityPriKey] [int] NULL,
[TTPriKey] [int] NOT NULL,
[AuthPriKey] [int] NULL,
[DTPriKey] [int] NULL,
[GLDefault] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MTGroupPriKey] [int] NULL,
[ManualGL] [smallint] NULL,
[OverrideGLNumber] [varchar] (66) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [PK_GLARAP] PRIMARY KEY CLUSTERED ([GLAPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [IX_GLARAP_UniqueColumns] UNIQUE NONCLUSTERED ([GLCPriKey], [TTPriKey], [AuthPriKey], [CommodityPriKey], [MTGroupPriKey], [DTPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_GLARAP_GLCPriKey] ON [dbo].[GLARAP] ([GLCPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_GLARAP_TTPriKey] ON [dbo].[GLARAP] ([TTPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_AUTHORITYTYPES] FOREIGN KEY ([AuthPriKey]) REFERENCES [dbo].[AuthorityTypes] ([AuthPriKey])
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_CommType] FOREIGN KEY ([CommodityPriKey]) REFERENCES [dbo].[CommType] ([PriKey])
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_DriverTypes] FOREIGN KEY ([DTPriKey]) REFERENCES [dbo].[DriverTypes] ([DTPriKey])
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_GLControl] FOREIGN KEY ([GLCPriKey]) REFERENCES [dbo].[GLControl] ([GLCPriKey])
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_MoveTypeGroups] FOREIGN KEY ([MTGroupPriKey]) REFERENCES [dbo].[MoveTypeGroups] ([MTGroupPriKey])
GO
ALTER TABLE [dbo].[GLARAP] ADD CONSTRAINT [FK_GLARAP_TransactionType] FOREIGN KEY ([TTPriKey]) REFERENCES [dbo].[TransactionType] ([TTPriKey])
GO
GRANT SELECT ON [dbo].[GLARAP] TO [MssExec]
GRANT INSERT ON [dbo].[GLARAP] TO [MssExec]
GRANT DELETE ON [dbo].[GLARAP] TO [MssExec]
GRANT UPDATE ON [dbo].[GLARAP] TO [MssExec]
GO