[dbo].[AccountProfilePresetAddress]
CREATE TABLE [dbo].[AccountProfilePresetAddress]
(
[AccountProfilePresetAddressID] [int] NOT NULL IDENTITY(1, 1),
[AccountProfilePresetFID] [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].[AccountProfilePresetAddress] ADD CONSTRAINT [CK_AccountProfilePresetAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[AccountProfilePresetAddress] ADD CONSTRAINT [PK_AccountProfilePresetAddress] PRIMARY KEY NONCLUSTERED ([AccountProfilePresetAddressID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfilePresetAddress] ADD CONSTRAINT [IX_AccountProfilePresetAddress_AddressType] UNIQUE NONCLUSTERED ([AccountProfilePresetFID], [AddressTypeFID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_AccountProfilePresetAddress_AccountProfilePresetFID] ON [dbo].[AccountProfilePresetAddress] ([AccountProfilePresetFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfilePresetAddress] ADD CONSTRAINT [FK_AccountProfilePresetAddress_AccountProfilePreset] FOREIGN KEY ([AccountProfilePresetFID]) REFERENCES [dbo].[AccountProfilePreset] ([AccountProfilePresetID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AccountProfilePresetAddress] ADD CONSTRAINT [FK_AccountProfilePresetAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[AccountProfilePresetAddress] ADD CONSTRAINT [FK_AccountProfilePresetAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
GRANT SELECT ON [dbo].[AccountProfilePresetAddress] TO [MssExec]
GRANT INSERT ON [dbo].[AccountProfilePresetAddress] TO [MssExec]
GRANT DELETE ON [dbo].[AccountProfilePresetAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[AccountProfilePresetAddress] TO [MssExec]
GO