Properties

Owner: Sales 
Creation Date: 04/26/2006 
Located On: PRIMARY 
Data Size KB:
Index Size KB: 24 
Rows: 17 
Description: Sales representative transfers to other sales territories. 

Columns

Name Data Type Length NULL Default IsIdentity IsGUID Description
    SalesPersonID  int          Primary key for SalesTerritoryHistory records. 
    TerritoryID  int          Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID. 
    StartDate  datetime          Date the sales representive started work in the territory. 
    EndDate  datetime          Date the sales representative left work in the territory. 
    rowguid  uniqueidentifier  16    (newid())      ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. 
    ModifiedDate  datetime    (getdate())      Date and time the record was last updated. 
Total: 6 column(s)

Indexes

Index Primary Unique Description
  PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID      Primary key (clustered) constraint 
  AK_SalesTerritoryHistory_rowguid      Unique nonclustered index. Used to support replication samples. 
Total: 2 index(es)

Check Constraints

Name Expression
  CK_SalesTerritoryHistory_EndDate  ([EndDate]>=[StartDate] OR [EndDate] IS NULL) 
Total: 1 constraint(s)

Referenced Tables

Table Foreign Key Primary Key or Unique Constraint
  Sales.SalesPerson  FK_SalesTerritoryHistory_SalesPerson_SalesPersonID  PK_SalesPerson_SalesPersonID 
  Sales.SalesTerritory  FK_SalesTerritoryHistory_SalesTerritory_TerritoryID  PK_SalesTerritory_TerritoryID 
Total: 2 table(s)

Objects that [Sales].[SalesTerritoryHistory] depends on

Object Name Owner Object Type Dep Level
  Flag  dbo  User Defined type 
  Name  dbo  User Defined type 
  NameStyle  dbo  User Defined type 
  Phone  dbo  User Defined type 
  Contact  Person  Table 
  SalesTerritory  Sales  Table 
  Employee  HumanResources  Table 
  SalesPerson  Sales  Table 
Total: 8 object(s)

SQL

CREATE TABLE [SalesTerritoryHistory] (
    [SalesPersonID] [int] NOT NULL ,
    [TerritoryID] [int] NOT NULL ,
    [StartDate] [datetime] NOT NULL ,
    [EndDate] [datetime] NULL ,
    [rowguid]  uniqueidentifier ROWGUIDCOL  NOT NULL CONSTRAINT [DF_SalesTerritoryHistory_rowguid] DEFAULT (newid()),
    [ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesTerritoryHistory_ModifiedDate] DEFAULT (getdate()),
    CONSTRAINT [PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID] PRIMARY KEY  CLUSTERED
    (
        [SalesPersonID],
        [StartDate],
        [TerritoryID]
    )  ON [PRIMARY] ,
    CONSTRAINT [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID] FOREIGN KEY
    (
        [SalesPersonID]
    ) REFERENCES [SalesPerson] (
        [SalesPersonID]
    ),
    CONSTRAINT [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID] FOREIGN KEY
    (
        [TerritoryID]
    ) REFERENCES [SalesTerritory] (
        [TerritoryID]
    ),
    CONSTRAINT [CK_SalesTerritoryHistory_EndDate] CHECK ([EndDate]>=[StartDate] OR [EndDate] IS NULL)
) ON [PRIMARY]
GO


See Also

List of tables