[dbo].[AccountAddress]
This table is used to store address information for a national account
CREATE TABLE [dbo].[AccountAddress]
(
[AccountAddressID] [int] NOT NULL IDENTITY(1, 1),
[AccountFID] [int] NOT NULL,
[AddressTypeFID] [int] NOT 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].[AccountAddress] ADD CONSTRAINT [CK_AccountAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[AccountAddress] ADD CONSTRAINT [PK_AccountAddress] PRIMARY KEY CLUSTERED ([AccountAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountAddress] ADD CONSTRAINT [IX_AccountAddress_AddressType] UNIQUE NONCLUSTERED ([AccountFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountAddress] ADD CONSTRAINT [FK_AccountAddress_Account] FOREIGN KEY ([AccountFID]) REFERENCES [dbo].[Accounts] ([AccountPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AccountAddress] ADD CONSTRAINT [FK_AccountAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[AccountAddress] ADD CONSTRAINT [FK_AccountAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
GRANT SELECT ON [dbo].[AccountAddress] TO [MssExec]
GRANT INSERT ON [dbo].[AccountAddress] TO [MssExec]
GRANT DELETE ON [dbo].[AccountAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[AccountAddress] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'This table is used to store address information for a national account', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key of this table', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'AccountAddressID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a national account record', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'AccountFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'First line of the street address for a national account ', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'Address1'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Second line of the street address for a national account ', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'Address2'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Third line of the street address for a national account ', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', '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'AccountAddress', 'COLUMN', N'AddressTypeFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'City of a national account address', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'City'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key associating a record to a country code', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'CountryCodeStandardFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Postal mailing code of a national account ', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'PostalCode'
GO
EXEC sp_addextendedproperty N'MS_Description', N'State of a national account address', 'SCHEMA', N'dbo', 'TABLE', N'AccountAddress', 'COLUMN', N'State'
GO