Tables [Sales].[SalesTerritoryHistory]
Sales representative transfers to other sales territories.
PropertyValue
Row Count (~)17
Created13:14:19 14 marca 2012
Last Modified13:14:55 14 marca 2012
KeyNameData TypeMax Length (Bytes)Allow NullsDefaultDescription
Cluster Primary Key PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID: BusinessEntityID\StartDate\TerritoryIDForeign Keys FK_SalesTerritoryHistory_SalesPerson_BusinessEntityID: [Sales].[SalesPerson].BusinessEntityIDBusinessEntityIDint4
False
Primary key. The sales rep.  Foreign key to SalesPerson.BusinessEntityID.
Cluster Primary Key PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID: BusinessEntityID\StartDate\TerritoryIDForeign Keys FK_SalesTerritoryHistory_SalesTerritory_TerritoryID: [Sales].[SalesTerritory].TerritoryIDTerritoryIDint4
False
Primary key. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID.
Cluster Primary Key PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID: BusinessEntityID\StartDate\TerritoryIDStartDatedatetime8
False
Primary key. Date the sales representive started work in the territory.
EndDatedatetime8
True
Date the sales representative left work in the territory.
Indexes AK_SalesTerritoryHistory_rowguidrowguiduniqueidentifier16
False
(newid())ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
ModifiedDatedatetime8
False
(getdate())Date and time the record was last updated.
KeyNameKey ColumnsUniqueDescription
Cluster Primary Key PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID: BusinessEntityID\StartDate\TerritoryIDPK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryIDBusinessEntityID, StartDate, TerritoryID
True
Primary key (clustered) constraint
AK_SalesTerritoryHistory_rowguidrowguid
True
Unique nonclustered index. Used to support replication samples.
NameConstraintDescription
CK_SalesTerritoryHistory_EndDate([EndDate]>=[StartDate] OR [EndDate] IS NULL)Check constraint [EndDate] >= [StartDate] OR [EndDate] IS NULL
NameColumnsDescription
FK_SalesTerritoryHistory_SalesPerson_BusinessEntityIDBusinessEntityID->[Sales].[SalesPerson].[BusinessEntityID]Foreign key constraint referencing SalesPerson.SalesPersonID.
FK_SalesTerritoryHistory_SalesTerritory_TerritoryIDTerritoryID->[Sales].[SalesTerritory].[TerritoryID]Foreign key constraint referencing SalesTerritory.TerritoryID.
CREATE TABLE [Sales].[SalesTerritoryHistory]
(
[BusinessEntityID] [int] NOT NULL,
[TerritoryID] [int] NOT NULL,
[StartDate] [datetime] NOT NULL,
[EndDate] [datetime] NULL,
[rowguid] [uniqueidentifier] NOT NULL ROWGUIDCOL CONSTRAINT [DF_SalesTerritoryHistory_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesTerritoryHistory_ModifiedDate] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [Sales].[SalesTerritoryHistory] ADD CONSTRAINT [CK_SalesTerritoryHistory_EndDate] CHECK (([EndDate]>=[StartDate] OR [EndDate] IS NULL))
GO
ALTER TABLE [Sales].[SalesTerritoryHistory] ADD CONSTRAINT [PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID] PRIMARY KEY CLUSTERED  ([BusinessEntityID], [StartDate], [TerritoryID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [AK_SalesTerritoryHistory_rowguid] ON [Sales].[SalesTerritoryHistory] ([rowguid]) ON [PRIMARY]
GO
ALTER TABLE [Sales].[SalesTerritoryHistory] ADD CONSTRAINT [FK_SalesTerritoryHistory_SalesPerson_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [Sales].[SalesPerson] ([BusinessEntityID])
GO
ALTER TABLE [Sales].[SalesTerritoryHistory] ADD CONSTRAINT [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID] FOREIGN KEY ([TerritoryID]) REFERENCES [Sales].[SalesTerritory] ([TerritoryID])
GO
EXEC sp_addextendedproperty N'MS_Description', N'Sales representative transfers to other sales territories.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key. The sales rep.  Foreign key to SalesPerson.BusinessEntityID.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'BusinessEntityID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Date the sales representative left work in the territory.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'EndDate'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Date and time the record was last updated.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'ModifiedDate'
GO
EXEC sp_addextendedproperty N'MS_Description', N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'rowguid'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key. Date the sales representive started work in the territory.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'StartDate'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'COLUMN', N'TerritoryID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Check constraint [EndDate] >= [StartDate] OR [EndDate] IS NULL', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'CK_SalesTerritoryHistory_EndDate'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Default constraint value of GETDATE()', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'DF_SalesTerritoryHistory_ModifiedDate'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Default constraint value of NEWID()', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'DF_SalesTerritoryHistory_rowguid'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Foreign key constraint referencing SalesPerson.SalesPersonID.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'FK_SalesTerritoryHistory_SalesPerson_BusinessEntityID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Foreign key constraint referencing SalesTerritory.TerritoryID.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'FK_SalesTerritoryHistory_SalesTerritory_TerritoryID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key (clustered) constraint', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'CONSTRAINT', N'PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Unique nonclustered index. Used to support replication samples.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'INDEX', N'AK_SalesTerritoryHistory_rowguid'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Clustered index created by a primary key constraint.', 'SCHEMA', N'Sales', 'TABLE', N'SalesTerritoryHistory', 'INDEX', N'PK_SalesTerritoryHistory_BusinessEntityID_StartDate_TerritoryID'
GO