[dbo].[AccountProfileContactAddress]
This table is used to store address information for contacts of a national account
CREATE TABLE [dbo].[AccountProfileContactAddress]
(
[AccountProfileContactAddressID] [int] NOT NULL IDENTITY(1, 1),
[AccountProfileContactFID] [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].[AccountProfileContactAddress] ADD CONSTRAINT [CK_AccountProfileContactAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[AccountProfileContactAddress] ADD CONSTRAINT [PK_AccountProfileContactAddress] PRIMARY KEY NONCLUSTERED ([AccountProfileContactAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfileContactAddress] ADD CONSTRAINT [IX_AccountProfileContactAddress_AddressType] UNIQUE NONCLUSTERED ([AccountProfileContactFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfileContactAddress] ADD CONSTRAINT [FK_AccountProfileContactAddress_AccountProfileContact] FOREIGN KEY ([AccountProfileContactFID]) REFERENCES [dbo].[AccountProfileContacts] ([AccountProfileContactID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AccountProfileContactAddress] ADD CONSTRAINT [FK_AccountProfileContactAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[AccountProfileContactAddress] ADD CONSTRAINT [FK_AccountProfileContactAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
GRANT SELECT ON [dbo].[AccountProfileContactAddress] TO [MssExec]
GRANT INSERT ON [dbo].[AccountProfileContactAddress] TO [MssExec]
GRANT DELETE ON [dbo].[AccountProfileContactAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[AccountProfileContactAddress] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'This table is used to store address information for contacts of a national account', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key of this table', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'AccountProfileContactAddressID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a national account contact record', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'AccountProfileContactFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'First line of the street address for a national account contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'Address1'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Second line of the street address for a national account contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'Address2'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Third line of the street address for a national account contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'Address3'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key associating a record to a particular address type', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'AddressTypeFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'City of a national account address contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'City'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key associating a record to a country code', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'CountryCodeStandardFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Postal mailing code of a national account address contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'PostalCode'
GO
EXEC sp_addextendedproperty N'MS_Description', N'State of a national account address contact', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfileContactAddress', 'COLUMN', N'State'
GO