CREATE TABLE [dbo].[AccountProfiles]
(
[AccountProfileID] [int] NOT NULL IDENTITY(1, 1),
[Name] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ContractMasterFID] [int] NULL,
[ProfileFID] [int] NULL,
[RolloutFID] [int] NULL,
[RatePlanFID] [int] NULL,
[CoordinatorFID] [int] NULL,
[SalesPersonFID] [int] NULL,
[LogisticCoordinatorFID] [int] NULL,
[RevenueClerkFID] [int] NULL,
[AccountFID] [int] NULL,
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SpecInstOrig] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SpecInstDest] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToContact] [varchar] (61) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToAddr] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToCity] [varchar] (26) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToState] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToZip] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GeneralNotes] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CustomerAddressCode] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillToCountryName] [varchar] (61) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[InvoiceTermsOverrideOptionFID] [int] NOT NULL CONSTRAINT [DF_AccountProfiles_InvoiceTermsOverrideOptionFID] DEFAULT ((1)),
[ValuationFID] [int] NULL,
[ValuationPerPoundFID] [int] NULL,
[Inactive] [bit] NOT NULL CONSTRAINT [DF_AccountProfiles_Inactive] DEFAULT ((0)),
[LaborRatingGroupFID] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [PK_AccountProfiles] PRIMARY KEY NONCLUSTERED ([AccountProfileID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AccountProfiles_CoordinatorFID] ON [dbo].[AccountProfiles] ([CoordinatorFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AccountProfiles_LogisticCoordinatorFID] ON [dbo].[AccountProfiles] ([LogisticCoordinatorFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AccountProfiles_RevenueClerkFID] ON [dbo].[AccountProfiles] ([RevenueClerkFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AccountProfiles_SalesPersonFID] ON [dbo].[AccountProfiles] ([SalesPersonFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Accounts] FOREIGN KEY ([AccountFID]) REFERENCES [dbo].[Accounts] ([AccountPriKey])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_ContractMaster] FOREIGN KEY ([ContractMasterFID]) REFERENCES [dbo].[ContractMaster] ([CMPriKey])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Sysuser] FOREIGN KEY ([CoordinatorFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_InvoiceTermsOverrideOption] FOREIGN KEY ([InvoiceTermsOverrideOptionFID]) REFERENCES [dbo].[InvoiceTermsOverrideOption] ([InvoiceTermsOverrideOptionID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_LaborRatingGroup] FOREIGN KEY ([LaborRatingGroupFID]) REFERENCES [dbo].[LaborRatingGroup] ([LaborRatingGroupID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Sysuser2] FOREIGN KEY ([LogisticCoordinatorFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_PROFILES] FOREIGN KEY ([ProfileFID]) REFERENCES [dbo].[Profiles] ([ProfileID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_RatePlans] FOREIGN KEY ([RatePlanFID]) REFERENCES [dbo].[RatePlans] ([RPPriKey])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Sysuser3] FOREIGN KEY ([RevenueClerkFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Rollouts] FOREIGN KEY ([RolloutFID]) REFERENCES [dbo].[RollOuts] ([RollOutID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Sysuser1] FOREIGN KEY ([SalesPersonFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[AccountProfiles] ADD CONSTRAINT [FK_AccountProfiles_Valuation] FOREIGN KEY ([ValuationFID]) REFERENCES [dbo].[Valuation] ([ValuationID])
GO
GRANT SELECT ON [dbo].[AccountProfiles] TO [MssExec]
GRANT INSERT ON [dbo].[AccountProfiles] TO [MssExec]
GRANT DELETE ON [dbo].[AccountProfiles] TO [MssExec]
GRANT UPDATE ON [dbo].[AccountProfiles] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'This table stores information on profiles associated to a particular national account as created through the Account Profile Management interface', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular national account', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'AccountFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key of this table', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'AccountProfileID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Street address for the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToAddr'
GO
EXEC sp_addextendedproperty N'MS_Description', N'City for the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToCity'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Default billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToContact'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Country of the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToCountryName'
GO
EXEC sp_addextendedproperty N'MS_Description', N'State for the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToState'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Postal mailing code for the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'BillToZip'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular contract master ', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'ContractMasterFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular coordinator', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'CoordinatorFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Code used to identify the customer address, such as �PRIMARY�, and is generally used for third party applications', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'CustomerAddressCode'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Identification number of the customer assigned to the profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'CustomerNumber'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Postal mailing code for the billing contact person for the national account profile', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'GeneralNotes'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular invoice terms override option', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'InvoiceTermsOverrideOptionFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular logistics coordinator', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'LogisticCoordinatorFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Name of a particular account profile record', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'Name'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular profile (Task Definition)', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'ProfileFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular rate plan', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'RatePlanFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular revenue clerk', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'RevenueClerkFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular rollout (Task Group)', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'RolloutFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular sales person', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'SalesPersonFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Default special destination instructions to be associated to the profile when it is assigned to an order', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'SpecInstDest'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Default special origin instructions to be associated to the profile when it is assigned to an order', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'SpecInstOrig'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular valuation option', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'ValuationFID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Key linking this table to a particular valuation per pound option ', 'SCHEMA', N'dbo', 'TABLE', N'AccountProfiles', 'COLUMN', N'ValuationPerPoundFID'
GO