CREATE TABLE [dbo].[AgentPhoneNumber]
(
[AgentPhoneNumberID] [int] NOT NULL IDENTITY(1, 1),
[AgentFID] [int] NOT NULL,
[AgentPhoneTypeFID] [int] NOT NULL,
[CountryCodeStandardFID] [int] NULL,
[AreaCode] [dbo].[PhoneAreaCode] NULL,
[LocalNumber] [dbo].[PhoneLocalNumber] NULL,
[Extension] [dbo].[PhoneExtension] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentPhoneNumber] ADD CONSTRAINT [PK_AgentPhoneNumber] PRIMARY KEY NONCLUSTERED ([AgentPhoneNumberID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentPhoneNumber] ADD CONSTRAINT [IX_AgentPhoneNumber_AgentAndPhoneType] UNIQUE CLUSTERED ([AgentFID], [AgentPhoneTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentPhoneNumber] ADD CONSTRAINT [FK_AgentPhoneNumber_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AgentPhoneNumber] ADD CONSTRAINT [FK_AgentPhoneNumber_AgentPhoneType] FOREIGN KEY ([AgentPhoneTypeFID]) REFERENCES [dbo].[AgentPhoneType] ([AgentPhoneTypeID])
GO
ALTER TABLE [dbo].[AgentPhoneNumber] ADD CONSTRAINT [FK_AgentPhoneNumber_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
GRANT SELECT ON [dbo].[AgentPhoneNumber] TO [MssExec]
GRANT INSERT ON [dbo].[AgentPhoneNumber] TO [MssExec]
GRANT DELETE ON [dbo].[AgentPhoneNumber] TO [MssExec]
GRANT UPDATE ON [dbo].[AgentPhoneNumber] TO [MssExec]
GO