[dbo].[StatementDetailAddress]
CREATE TABLE [dbo].[StatementDetailAddress]
(
[StatementDetailAddressID] [int] NOT NULL IDENTITY(1, 1),
[StatementDetailContactFID] [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,
[CountryCodeStandardFID] [int] NULL,
[PostalCode] [dbo].[AddressPostalCode] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [CK_StatementDetailAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [PK_StatementDetailAddress] PRIMARY KEY NONCLUSTERED ([StatementDetailAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [IX_StatementDetailAddress_AddressType] UNIQUE NONCLUSTERED ([StatementDetailContactFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [FK_StatementDetailAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [FK_StatementDetailAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[StatementDetailAddress] ADD CONSTRAINT [FK_StatementDetailAddress_StatementDetailContact] FOREIGN KEY ([StatementDetailContactFID]) REFERENCES [dbo].[StatementDetailContact] ([StatementDetailContactID])
GO
GRANT SELECT ON [dbo].[StatementDetailAddress] TO [MssExec]
GRANT INSERT ON [dbo].[StatementDetailAddress] TO [MssExec]
GRANT DELETE ON [dbo].[StatementDetailAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[StatementDetailAddress] TO [MssExec]
GO