CREATE TABLE [dbo].[Agent]
(
[AgentID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Name] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[County] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Memo] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[AgentPriKey] [int] NOT NULL IDENTITY(1, 1),
[VLPriKey] [int] NOT NULL,
[VendorID] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsActive] [bit] NOT NULL CONSTRAINT [DF_Agent_IsActive] DEFAULT ((1)),
[HaulOwnAuthority] [bit] NOT NULL CONSTRAINT [DF_Agent_HaulOwnAuthority] DEFAULT ((0)),
[HaulVanLineAuthority] [bit] NOT NULL CONSTRAINT [DF_Agent_HaulVanLineAuthority] DEFAULT ((0)),
[IsForwardingAgent] [bit] NOT NULL CONSTRAINT [DF_Agent_IsForwardingAgent] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Agent] ADD CONSTRAINT [CK_Agent_Name] CHECK (([Name]<>''))
GO
ALTER TABLE [dbo].[Agent] ADD CONSTRAINT [PK_AGENT] PRIMARY KEY CLUSTERED ([AgentPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Agent] ADD CONSTRAINT [IX_Agent_AgentIDVLPriKey] UNIQUE NONCLUSTERED ([AgentID], [VLPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Agent] ADD CONSTRAINT [FK_AGENT_VANLINE] FOREIGN KEY ([VLPriKey]) REFERENCES [dbo].[VanLine] ([VLPriKey])
GO
GRANT SELECT ON [dbo].[Agent] TO [MssExec]
GRANT INSERT ON [dbo].[Agent] TO [MssExec]
GRANT DELETE ON [dbo].[Agent] TO [MssExec]
GRANT UPDATE ON [dbo].[Agent] TO [MssExec]
GO