Northwind Database (Document! X Sample)
AdventureWorks Database / Sales Schema / Sales.SalesTerritory Table
In This Topic
    Sales.SalesTerritory Table
    In This Topic
    Description
    Sales territory lookup table.
    Properties
    Creation Date27/10/2017 14:33
    File GroupPRIMARY
    Text File Group
    System Object
    Published for Replication
    Rows10
    Data Space Used8.00 KB
    Index Space Used40.00 KB
    Columns
     Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
    Primary Key Primary key for SalesTerritory records.Integer4   
     Sales territory descriptiondbo.Name50   
     ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. VarWChar3   
     Geographic area to which the sales territory belong.VarWChar50   
     Sales in the territory year to date.Currency8 
    ((0.00))
     
     Sales in the territory the previous year.Currency8 
    ((0.00))
     
     Business costs in the territory year to date.Currency8 
    ((0.00))
     
     Business costs in the territory the previous year.Currency8 
    ((0.00))
     
     ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.GUID16 
    (newid())
     
     Date and time the record was last updated.DBTimeStamp4 
    (getdate())
     
    Indexes
    IndexDescriptionPrimaryUnique
    Unique nonclustered index. 
    Unique nonclustered index. Used to support replication samples. 
    Primary key (clustered) constraint
    Check Constraints
    NameDescriptionExpression
    Check constraint [CostLastYear] >= (0.00)
    ([CostLastYear]>=(0.00))
    Check constraint [CostYTD] >= (0.00)
    ([CostYTD]>=(0.00))
    Check constraint [SalesLastYear] >= (0.00)
    ([SalesLastYear]>=(0.00))
    Check constraint [SalesYTD] >= (0.00)
    ([SalesYTD]>=(0.00))
    Relationships
    RelationshipDescription
    Foreign key constraint referencing CountryRegion.CountryRegionCode.
    Objects that depend on Sales.SalesTerritory
     Database ObjectObject TypeDescriptionDep Level
    Person.Address tablePerson.AddressTableStreet address information for customers, employees, and vendors.1
    Person.BusinessEntityAddress tablePerson.BusinessEntityAddressTableCross-reference table mapping customers, vendors, and employees to their addresses.1
    Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Person and Store tables.2
    iduSalesOrderDetail triggeriduSalesOrderDetailTriggerAFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.3
    Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.2
    Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.1
    Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.3
    Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.2
    Sales.SalesPersonQuotaHistory tableSales.SalesPersonQuotaHistoryTableSales performance tracking.2
    Sales.SalesTaxRate tableSales.SalesTaxRateTableTax rate lookup table.2
    Sales.SalesTerritoryHistory tableSales.SalesTerritoryHistoryTableSales representative transfers to other sales territories.1
    Person.StateProvince tablePerson.StateProvinceTableState and province lookup table.1
    Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.1
    uSalesOrderHeader triggeruSalesOrderHeaderTriggerAFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.3
    HumanResources.vEmployee viewHumanResources.vEmployeeViewEmployee names and addresses.2
    Sales.vIndividualCustomer viewSales.vIndividualCustomerViewIndividual customers (names and addresses) that purchase Adventure Works Cycles products online.2
    Sales.vSalesPerson viewSales.vSalesPersonViewSales representiatives (names and addresses) and their sales-related information.1
    Sales.vSalesPersonSalesByFiscalYears viewSales.vSalesPersonSalesByFiscalYearsViewUses PIVOT to return aggregated sales information for each sales representative.3
    Person.vStateProvinceCountryRegion viewPerson.vStateProvinceCountryRegionViewJoins StateProvince table with CountryRegion table.2
    Sales.vStoreWithContacts viewSales.vStoreWithContactsViewStores (including store contacts) that sell Adventure Works Cycles products to consumers.1
    Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (including demographics) that sell Adventure Works Cycles products to consumers.1
    Purchasing.vVendorWithAddresses viewPurchasing.vVendorWithAddressesViewVendor (company) names and addresses .2
    Objects that Sales.SalesTerritory depends on
     Database ObjectObject TypeDescriptionDep Level
    Person.CountryRegion tablePerson.CountryRegionTableLookup table containing the ISO standard codes for countries and regions.4
    dbo.Name datatypedbo.NameUser Defined Data Type 2
    SQL
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    CREATE TABLE [Sales].[SalesTerritory](
        [TerritoryID] [int] IDENTITY(1,1) NOT NULL,
        [Name] [dbo].[Name] NOT NULL,
        [CountryRegionCode] [nvarchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [Group] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [SalesYTD] [money] NOT NULL,
        [SalesLastYear] [money] NOT NULL,
        [CostYTD] [money] NOT NULL,
        [CostLastYear] [money] NOT NULL,
        [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
        [ModifiedDate] [datetime] NOT NULL,
     CONSTRAINT [PK_SalesTerritory_TerritoryID] PRIMARY KEY CLUSTERED 
    (
        [TerritoryID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_SalesYTD]  DEFAULT ((0.00)) FOR [SalesYTD]
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_SalesLastYear]  DEFAULT ((0.00)) FOR [SalesLastYear]
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_CostYTD]  DEFAULT ((0.00)) FOR [CostYTD]
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_CostLastYear]  DEFAULT ((0.00)) FOR [CostLastYear]
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_rowguid]  DEFAULT (newid()) FOR [rowguid]
    ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
    ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [FK_SalesTerritory_CountryRegion_CountryRegionCode] FOREIGN KEY([CountryRegionCode])
    REFERENCES [Person].[CountryRegion] ([CountryRegionCode])
    ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [FK_SalesTerritory_CountryRegion_CountryRegionCode]
    ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_CostLastYear] CHECK  (([CostLastYear]>=(0.00)))
    ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_CostLastYear]
    ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_CostYTD] CHECK  (([CostYTD]>=(0.00)))
    ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_CostYTD]
    ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_SalesLastYear] CHECK  (([SalesLastYear]>=(0.00)))
    ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_SalesLastYear]
    ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_SalesYTD] CHECK  (([SalesYTD]>=(0.00)))
    ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_SalesYTD]
    See Also