[dbo].[AccountingCustomerAddress]
CREATE TABLE [dbo].[AccountingCustomerAddress]
(
[AccountingCustomerAddressId] [int] NOT NULL IDENTITY(1, 1),
[AccountingCustomerFid] [int] NOT NULL,
[AccountingCustomerAddressTypeFid] [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].[AccountingCustomerAddress] ADD CONSTRAINT [PK_AccountingCustomerAddress] PRIMARY KEY NONCLUSTERED ([AccountingCustomerAddressId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountingCustomerAddress] ADD CONSTRAINT [IX_AccountingCustomerAddress_AccountingCustomerFid_AccountingCustomerAddressTypeFid] UNIQUE CLUSTERED ([AccountingCustomerFid], [AccountingCustomerAddressTypeFid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountingCustomerAddress] ADD CONSTRAINT [FK_AccountingCustomerAddress_AccountingCustomerAddressType] FOREIGN KEY ([AccountingCustomerAddressTypeFid]) REFERENCES [dbo].[AccountingCustomerAddressType] ([AccountingCustomerAddressTypeId])
GO
ALTER TABLE [dbo].[AccountingCustomerAddress] ADD CONSTRAINT [FK_AccountingCustomerAddress_AccountingCustomer] FOREIGN KEY ([AccountingCustomerFid]) REFERENCES [dbo].[AccountingCustomer] ([AccountingCustomerId]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AccountingCustomerAddress] ADD CONSTRAINT [FK_AccountingCustomerAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
GRANT SELECT ON [dbo].[AccountingCustomerAddress] TO [MssExec]
GRANT INSERT ON [dbo].[AccountingCustomerAddress] TO [MssExec]
GRANT DELETE ON [dbo].[AccountingCustomerAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[AccountingCustomerAddress] TO [MssExec]
GO