CREATE TABLE [dbo].[SCBillingAccountCodes]
(
[BillingAccountCodeID] [int] NOT NULL IDENTITY(1, 1),
[BillingAccountCode] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingAccountCodes_Description] DEFAULT (''),
[LaborGLID] [int] NOT NULL,
[LaborDeptID] [int] NULL,
[LaborCostGLID] [int] NOT NULL,
[LaborCostDeptID] [int] NULL,
[LaborCostAppliedGLID] [int] NOT NULL,
[LaborCostAppliedDeptID] [int] NULL,
[TravelGLID] [int] NOT NULL,
[TravelDeptID] [int] NULL,
[TravelCostGLID] [int] NOT NULL,
[TravelCostDeptID] [int] NULL,
[TravelCostAppliedGLID] [int] NOT NULL,
[TravelCostAppliedDeptID] [int] NULL,
[MileageGLID] [int] NOT NULL,
[MileageDeptID] [int] NULL,
[MileageCostGLID] [int] NOT NULL,
[MileageCostDeptID] [int] NULL,
[MileageCostAppliedGLID] [int] NOT NULL,
[MileageCostAppliedDeptID] [int] NULL,
[MiscGLID] [int] NULL,
[MiscDeptID] [int] NULL,
[IncludedCogsGLID] [int] NULL,
[IncludedDeptID] [int] NULL,
[Active] [bit] NOT NULL CONSTRAINT [DF_SCBillingAccountCodes_Active] DEFAULT ((1)),
[CreatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[UpdatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_SCBillingAccountCodes_CreateDate] DEFAULT (getdate()),
[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_SCBillingAccountCodes_LastUpdate] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [PK_SCBillingAccountCodes] PRIMARY KEY CLUSTERED ([BillingAccountCodeID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [IX_SCBillingAccountCodes_BillingAccountCode] UNIQUE NONCLUSTERED ([BillingAccountCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_IncludedCogsGLID_GLAccounts] FOREIGN KEY ([IncludedCogsGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_IncludedDeptID_GLDepts] FOREIGN KEY ([IncludedDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborCostAppliedDeptID_GLDepts] FOREIGN KEY ([LaborCostAppliedDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborCostAppliedGLID_GLAccounts] FOREIGN KEY ([LaborCostAppliedGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborCostDeptID_GLDepts] FOREIGN KEY ([LaborCostDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborCostGLID_GLAccounts] FOREIGN KEY ([LaborCostGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborDeptID_GLDepts] FOREIGN KEY ([LaborDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_LaborGLID_GLAccounts] FOREIGN KEY ([LaborGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageCostAppliedDeptID_GLDepts] FOREIGN KEY ([MileageCostAppliedDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageCostAppliedGLID_GLAccounts] FOREIGN KEY ([MileageCostAppliedGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageCostDeptID_GLDepts] FOREIGN KEY ([MileageCostDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageCostGLID_GLAccounts] FOREIGN KEY ([MileageCostGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageDeptID_GLDepts] FOREIGN KEY ([MileageDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MileageGLID_GLAccounts] FOREIGN KEY ([MileageGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MiscDeptID_GLDepts] FOREIGN KEY ([MiscDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_MiscGLID_GLAccounts] FOREIGN KEY ([MiscGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelCostAppliedDeptID_GLDepts] FOREIGN KEY ([TravelCostAppliedDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelCostAppliedGLID_GLAccounts] FOREIGN KEY ([TravelCostAppliedGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelCostDeptID_GLDepts] FOREIGN KEY ([TravelCostDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelCostGLID_GLAccounts] FOREIGN KEY ([TravelCostGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelDeptID_GLDepts] FOREIGN KEY ([TravelDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingAccountCodes] ADD CONSTRAINT [FK_SCBillingAccountCodes_TravelGLID_GLAccounts] FOREIGN KEY ([TravelGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO