Owner: Sales 
Creation Date: 04/26/2006 
Located On: PRIMARY 
Data Size KB: 5592 
Index Size KB: 2384 
Rows: 31465 
Description: General sales order information. 


Name Data Type Length NULL Default IsIdentity IsGUID Description
    SalesOrderID  int          Primary key. 
    RevisionNumber  tinyint    ((0))      Incremental number to track changes to the sales order over time. 
    OrderDate  datetime    (getdate())      Dates the sales order was created. 
    DueDate  datetime          Date the order is due to the customer. 
    ShipDate  datetime          Date the order was shipped to the customer. 
    Status  tinyint    ((1))      Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled 
    OnlineOrderFlag  Flag    ((1))      0 = Order placed by sales person. 1 = Order placed online by customer. 
    SalesOrderNumber  nvarchar  25          Unique sales order identification number. 
    PurchaseOrderNumber  OrderNumber  50          Customer purchase order number reference.  
    AccountNumber  AccountNumber  30          Financial accounting number reference. 
    CustomerID  int          Customer identification number. Foreign key to Customer.CustomerID. 
    ContactID  int          Customer contact identification number. Foreign key to Contact.ContactID. 
    SalesPersonID  int          Sales person who created the sales order. Foreign key to SalesPerson.SalePersonID. 
    TerritoryID  int          Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. 
    BillToAddressID  int          Customer billing address. Foreign key to Address.AddressID. 
    ShipToAddressID  int          Customer shipping address. Foreign key to Address.AddressID. 
    ShipMethodID  int          Shipping method. Foreign key to ShipMethod.ShipMethodID. 
    CreditCardID  int          Credit card identification number. Foreign key to CreditCard.CreditCardID. 
    CreditCardApprovalCode  varchar  15          Approval code provided by the credit card company. 
    CurrencyRateID  int          Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. 
    SubTotal  money    ((0.00))      Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. 
    TaxAmt  money    ((0.00))      Tax amount. 
    Freight  money    ((0.00))      Shipping cost. 
    TotalDue  money          Total due from customer. Computed as Subtotal + TaxAmt + Freight. 
    Comment  nvarchar  128          Sales representative comments. 
    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: 27 column(s)

Identity column

Name Seed Increment Not for replication


Index Primary Unique Description
  PK_SalesOrderHeader_SalesOrderID      Primary key (clustered) constraint 
  IX_SalesOrderHeader_CustomerID      Nonclustered index. 
  IX_SalesOrderHeader_SalesPersonID      Nonclustered index. 
  AK_SalesOrderHeader_SalesOrderNumber      Unique nonclustered index. 
  AK_SalesOrderHeader_rowguid      Unique nonclustered index. Used to support replication samples. 
Total: 5 index(es)


Name Owner Instead Of Disabled Table/View Description
  uSalesOrderHeader  Sales      Sales.SalesOrderHeader  AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. 
Total: 1 trigger(s)

Check Constraints

Name Expression
  CK_SalesOrderHeader_DueDate  ([DueDate]>=[OrderDate]) 
  CK_SalesOrderHeader_Freight  ([Freight]>=(0.00)) 
  CK_SalesOrderHeader_ShipDate  ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL) 
  CK_SalesOrderHeader_Status  ([Status]>=(0) AND [Status]<=(8)) 
  CK_SalesOrderHeader_SubTotal  ([SubTotal]>=(0.00)) 
  CK_SalesOrderHeader_TaxAmt  ([TaxAmt]>=(0.00)) 
Total: 6 constraint(s)

Referencing Tables

Table Foreign Key Primary Key or Unique Constraint
  Sales.SalesOrderDetail  FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID  PK_SalesOrderHeader_SalesOrderID 
  Sales.SalesOrderHeaderSalesReason  FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID  PK_SalesOrderHeader_SalesOrderID 
Total: 2 table(s)

Referenced Tables

Table Foreign Key Primary Key or Unique Constraint
  Person.Address  FK_SalesOrderHeader_Address_BillToAddressID  PK_Address_AddressID 
  Person.Address  FK_SalesOrderHeader_Address_ShipToAddressID  PK_Address_AddressID 
  Person.Contact  FK_SalesOrderHeader_Contact_ContactID  PK_Contact_ContactID 
  Sales.CreditCard  FK_SalesOrderHeader_CreditCard_CreditCardID  PK_CreditCard_CreditCardID 
  Sales.CurrencyRate  FK_SalesOrderHeader_CurrencyRate_CurrencyRateID  PK_CurrencyRate_CurrencyRateID 
  Sales.Customer  FK_SalesOrderHeader_Customer_CustomerID  PK_Customer_CustomerID 
  Sales.SalesPerson  FK_SalesOrderHeader_SalesPerson_SalesPersonID  PK_SalesPerson_SalesPersonID 
  Sales.SalesTerritory  FK_SalesOrderHeader_SalesTerritory_TerritoryID  PK_SalesTerritory_TerritoryID 
  Purchasing.ShipMethod  FK_SalesOrderHeader_ShipMethod_ShipMethodID  PK_ShipMethod_ShipMethodID 
Total: 9 table(s)

Objects that [Sales].[SalesOrderHeader] depends on

Object Name Owner Object Type Dep Level
  AccountNumber  dbo  User Defined type 
  Flag  dbo  User Defined type 
  Name  dbo  User Defined type 
  NameStyle  dbo  User Defined type 
  OrderNumber  dbo  User Defined type 
  Phone  dbo  User Defined type 
  ufnLeadingZeros  dbo  Function 
  Contact  Person  Table 
  CountryRegion  Person  Table 
  CreditCard  Sales  Table 
  Currency  Sales  Table 
  SalesTerritory  Sales  Table 
  ShipMethod  Purchasing  Table 
  CurrencyRate  Sales  Table 
  Customer  Sales  Table 
  Employee  HumanResources  Table 
  StateProvince  Person  Table 
  Address  Person  Table 
  SalesPerson  Sales  Table 
Total: 19 object(s)

Objects that depend on [Sales].[SalesOrderHeader]

Object Name Owner Object Type Dep Level
  vSalesPersonSalesByFiscalYears  Sales  View 
  SalesOrderDetail  Sales  Table 
  SalesOrderHeaderSalesReason  Sales  Table 
  uSalesOrderHeader  Sales  Trigger 
  iduSalesOrderDetail  Sales  Trigger 
Total: 5 object(s)


CREATE TABLE [SalesOrderHeader] (
    [SalesOrderID] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
    [RevisionNumber] [tinyint] NOT NULL CONSTRAINT [DF_SalesOrderHeader_RevisionNumber] DEFAULT ((0)),
    [OrderDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderHeader_OrderDate] DEFAULT (getdate()),
    [DueDate] [datetime] NOT NULL ,
    [ShipDate] [datetime] NULL ,
    [Status] [tinyint] NOT NULL CONSTRAINT [DF_SalesOrderHeader_Status] DEFAULT ((1)),
    [OnlineOrderFlag] [Flag] NOT NULL CONSTRAINT [DF_SalesOrderHeader_OnlineOrderFlag] DEFAULT ((1)),
    [SalesOrderNumber] AS (isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID],0),N'*** ERROR ***')) ,
    [PurchaseOrderNumber] [OrderNumber] NULL ,
    [AccountNumber] [AccountNumber] NULL ,
    [CustomerID] [int] NOT NULL ,
    [ContactID] [int] NOT NULL ,
    [SalesPersonID] [int] NULL ,
    [TerritoryID] [int] NULL ,
    [BillToAddressID] [int] NOT NULL ,
    [ShipToAddressID] [int] NOT NULL ,
    [ShipMethodID] [int] NOT NULL ,
    [CreditCardID] [int] NULL ,
    [CreditCardApprovalCode] [varchar] (15) COLLATE Latin1_General_CS_AS NULL ,
    [CurrencyRateID] [int] NULL ,
    [SubTotal] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_SubTotal] DEFAULT ((0.00)),
    [TaxAmt] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_TaxAmt] DEFAULT ((0.00)),
    [Freight] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_Freight] DEFAULT ((0.00)),
    [TotalDue] AS (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))) ,
    [Comment] [nvarchar] (128) COLLATE Latin1_General_CS_AS NULL ,
    [rowguid]  uniqueidentifier ROWGUIDCOL  NOT NULL CONSTRAINT [DF_SalesOrderHeader_rowguid] DEFAULT (newid()),
    [ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderHeader_ModifiedDate] DEFAULT (getdate()),
    )  ON [PRIMARY] ,
    CONSTRAINT [FK_SalesOrderHeader_Address_BillToAddressID] FOREIGN KEY
    ) REFERENCES [Address] (
    CONSTRAINT [FK_SalesOrderHeader_Address_ShipToAddressID] FOREIGN KEY
    ) REFERENCES [Address] (
    CONSTRAINT [FK_SalesOrderHeader_Contact_ContactID] FOREIGN KEY
    ) REFERENCES [Contact] (
    CONSTRAINT [FK_SalesOrderHeader_CreditCard_CreditCardID] FOREIGN KEY
    ) REFERENCES [CreditCard] (
    CONSTRAINT [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID] FOREIGN KEY
    ) REFERENCES [CurrencyRate] (
    CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID] FOREIGN KEY
    ) REFERENCES [Customer] (
    CONSTRAINT [FK_SalesOrderHeader_SalesPerson_SalesPersonID] FOREIGN KEY
    ) REFERENCES [SalesPerson] (
    CONSTRAINT [FK_SalesOrderHeader_SalesTerritory_TerritoryID] FOREIGN KEY
    ) REFERENCES [SalesTerritory] (
    CONSTRAINT [FK_SalesOrderHeader_ShipMethod_ShipMethodID] FOREIGN KEY
    ) REFERENCES [ShipMethod] (
    CONSTRAINT [CK_SalesOrderHeader_DueDate] CHECK ([DueDate]>=[OrderDate]),
    CONSTRAINT [CK_SalesOrderHeader_Freight] CHECK ([Freight]>=(0.00)),
    CONSTRAINT [CK_SalesOrderHeader_ShipDate] CHECK ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL),
    CONSTRAINT [CK_SalesOrderHeader_Status] CHECK ([Status]>=(0) AND [Status]<=(8)),
    CONSTRAINT [CK_SalesOrderHeader_SubTotal] CHECK ([SubTotal]>=(0.00)),
    CONSTRAINT [CK_SalesOrderHeader_TaxAmt] CHECK ([TaxAmt]>=(0.00))

See Also

List of tables