CREATE TABLE [dbo].[AgentContact]
(
[AgentContactID] [int] NOT NULL IDENTITY(1, 1),
[AgentFID] [int] NOT NULL,
[Contact] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Title] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Email] [varchar] (120) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PrimaryContact] [bit] NOT NULL CONSTRAINT [DF_AgentContact_Primary] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentContact] ADD CONSTRAINT [CK_AgentContact_PrimaryContact] CHECK (((0)=[dbo].[AgentContactPrimaryContact]([AgentContactID],[AgentFID],[PrimaryContact])))
GO
ALTER TABLE [dbo].[AgentContact] ADD CONSTRAINT [PK_AgentContact] PRIMARY KEY NONCLUSTERED ([AgentContactID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ix_AgentContact_Agent] ON [dbo].[AgentContact] ([AgentFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AgentContact_AgentContactIDPrimaryContact] ON [dbo].[AgentContact] ([AgentFID], [PrimaryContact] DESC) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentContact] ADD CONSTRAINT [FK_AgentContact_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[AgentContact] TO [MssExec]
GRANT INSERT ON [dbo].[AgentContact] TO [MssExec]
GRANT DELETE ON [dbo].[AgentContact] TO [MssExec]
GRANT UPDATE ON [dbo].[AgentContact] TO [MssExec]
GO