CREATE TABLE [dbo].[RevGroups]
(
[RGPriKey] [int] NOT NULL IDENTITY(1, 1),
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Type] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ICPriKey] [int] NULL,
[SortOrder] [int] NULL,
[InvoiceFlag] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PreferredRevenueAgentFID] [int] NULL,
[IsStorageRevenueGroup] [bit] NOT NULL CONSTRAINT [DF_RevGroups_IsStorageRevenueGroup] DEFAULT ((0)),
[Inactive] [bit] NOT NULL CONSTRAINT [DF_RevGroups_Inactive] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RevGroups] ADD CONSTRAINT [CK_RevGroups_IsTheOneStorageRevenueGroup] CHECK (((1)>=[dbo].[GetStorageRevGroupsCount]()))
GO
ALTER TABLE [dbo].[RevGroups] ADD CONSTRAINT [PK_RevGroups] PRIMARY KEY CLUSTERED ([RGPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RevGroups] ADD CONSTRAINT [FK_RevGroups_ItemCode] FOREIGN KEY ([ICPriKey]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[RevGroups] ADD CONSTRAINT [FK_RevGroups_PreferredRevenueAgent] FOREIGN KEY ([PreferredRevenueAgentFID]) REFERENCES [dbo].[PreferredRevenueAgent] ([PreferredRevenueAgentID])
GO
GRANT SELECT ON [dbo].[RevGroups] TO [MssExec]
GRANT INSERT ON [dbo].[RevGroups] TO [MssExec]
GRANT DELETE ON [dbo].[RevGroups] TO [MssExec]
GRANT UPDATE ON [dbo].[RevGroups] TO [MssExec]
GO