Northwind Database (Document! X Sample)
AdventureWorks Database / Person Schema / Person.StateProvince Table
In This Topic
    Person.StateProvince Table
    In This Topic
    Description
    State and province lookup table.
    Properties
    Creation Date27/10/2017 14:33
    File GroupPRIMARY
    Text File Group
    System Object
    Published for Replication
    Rows181
    Data Space Used16.00 KB
    Index Space Used64.00 KB
    Columns
     Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
    Primary Key Primary key for StateProvince records.Integer4   
     ISO standard state or province code.WChar3   
     ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. VarWChar3   
     0 = StateProvinceCode exists. 1 = StateProvinceCode unavailable, using CountryRegionCode.dbo.Flag1 
    ((1))
     
     State or province description.dbo.Name50   
     ID of the territory in which the state or province is located. Foreign key to SalesTerritory.SalesTerritoryID.Integer4   
     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. 
    Unique nonclustered index. 
    Primary key (clustered) constraint
    Relationships
    RelationshipDescription
    Foreign key constraint referencing StateProvince.StateProvinceID.
    Foreign key constraint referencing StateProvince.StateProvinceID.
    Foreign key constraint referencing CountryRegion.CountryRegionCode.
    Foreign key constraint referencing SalesTerritory.TerritoryID.
    Objects that depend on Person.StateProvince
     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
    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.SalesTaxRate tableSales.SalesTaxRateTableTax rate lookup table.2
    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.vStoreWithAddresses viewSales.vStoreWithAddressesViewStores (including store addresses) that sell Adventure Works Cycles products to consumers.1
    Purchasing.vVendorWithAddresses viewPurchasing.vVendorWithAddressesViewVendor (company) names and addresses .2
    Objects that Person.StateProvince depends on
     Database ObjectObject TypeDescriptionDep Level
    Person.CountryRegion tablePerson.CountryRegionTableLookup table containing the ISO standard codes for countries and regions.4
    dbo.Flag datatypedbo.FlagUser Defined Data Type 4
    dbo.Name datatypedbo.NameUser Defined Data Type 2
    Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.3
    SQL
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    CREATE TABLE [Person].[StateProvince](
        [StateProvinceID] [int] IDENTITY(1,1) NOT NULL,
        [StateProvinceCode] [nchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [CountryRegionCode] [nvarchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [IsOnlyStateProvinceFlag] [dbo].[Flag] NOT NULL,
        [Name] [dbo].[Name] NOT NULL,
        [TerritoryID] [int] NOT NULL,
        [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
        [ModifiedDate] [datetime] NOT NULL,
     CONSTRAINT [PK_StateProvince_StateProvinceID] PRIMARY KEY CLUSTERED 
    (
        [StateProvinceID] 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 [Person].[StateProvince] ADD  CONSTRAINT [DF_StateProvince_IsOnlyStateProvinceFlag]  DEFAULT ((1)) FOR [IsOnlyStateProvinceFlag]
    ALTER TABLE [Person].[StateProvince] ADD  CONSTRAINT [DF_StateProvince_rowguid]  DEFAULT (newid()) FOR [rowguid]
    ALTER TABLE [Person].[StateProvince] ADD  CONSTRAINT [DF_StateProvince_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
    ALTER TABLE [Person].[StateProvince]  WITH CHECK ADD  CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode] FOREIGN KEY([CountryRegionCode])
    REFERENCES [Person].[CountryRegion] ([CountryRegionCode])
    ALTER TABLE [Person].[StateProvince] CHECK CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode]
    ALTER TABLE [Person].[StateProvince]  WITH CHECK ADD  CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID] FOREIGN KEY([TerritoryID])
    REFERENCES [Sales].[SalesTerritory] ([TerritoryID])
    ALTER TABLE [Person].[StateProvince] CHECK CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID]
    See Also