[dbo].[InternationalCustomsAgentAddress]
CREATE TABLE [dbo].[InternationalCustomsAgentAddress]
(
[InternationalCustomsAgentAddressID] [int] NOT NULL IDENTITY(1, 1),
[InternationalCustomsAgentFID] [int] NOT NULL,
[AddressTypeFID] [int] NULL,
[Address1] [dbo].[Address] NULL,
[Address2] [dbo].[Address] NULL,
[Address3] [dbo].[Address] NULL,
[City] [dbo].[AddressCity] NULL,
[State] [dbo].[AddressState] NULL,
[PostalCode] [dbo].[AddressPostalCode] NULL,
[CountryCodeStandardFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [CK_InternationalCustomsAgentAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [PK_InternationalCustomsAgentAddress] PRIMARY KEY CLUSTERED ([InternationalCustomsAgentAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [IX_InternationalCustomsAgent_AddressType] UNIQUE NONCLUSTERED ([InternationalCustomsAgentFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [FK_InternationalCustomsAgentAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [FK_InternationalCustomsAgentAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[InternationalCustomsAgentAddress] ADD CONSTRAINT [FK_InternationalCustomsAgentAddress_InternationalCustomsAgent] FOREIGN KEY ([InternationalCustomsAgentFID]) REFERENCES [dbo].[InternationalCustomsAgent] ([InternationalCustomsAgentID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[InternationalCustomsAgentAddress] TO [MssExec]
GRANT INSERT ON [dbo].[InternationalCustomsAgentAddress] TO [MssExec]
GRANT DELETE ON [dbo].[InternationalCustomsAgentAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[InternationalCustomsAgentAddress] TO [MssExec]
GO