Sales.SalesOrderHeader
Documentation | AdventureWorks |
Schema | Sales |
Name | SalesOrderHeader |
Module | Sales |
General sales order information.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | SalesOrderID | int | Identity | Primary key. | ||||
Primary key. Identity |
||||||||
2 | RevisionNumber | tinyint | Default: 0 | Incremental number to track changes to the sales order over time. | ||||
Incremental number to track changes to the sales order over time. Default: 0 |
||||||||
3 | OrderDate | datetime | Default: getdate() | Dates the sales order was created. | ||||
Dates the sales order was created. Default: getdate() |
||||||||
4 | DueDate | datetime | Date the order is due to the customer. | |||||
Date the order is due to the customer. |
||||||||
5 | ShipDate | datetime | Date the order was shipped to the customer. | |||||
Date the order was shipped to the customer. |
||||||||
6 | Status | tinyint | Default: 1 | Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled | ||||
Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled Default: 1 |
||||||||
7 | OnlineOrderFlag | bit | Default: 1 | 0 = Order placed by sales person. 1 = Order placed online by customer. | ||||
0 = Order placed by sales person. 1 = Order placed online by customer. Default: 1 |
||||||||
8 | SalesOrderNumber | nvarchar(25) | Computed: isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID]),N'*** ERROR ***') | Unique sales order identification number. | ||||
Unique sales order identification number. Computed: isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID]),N'*** ERROR ***') |
||||||||
9 | PurchaseOrderNumber | nvarchar(25) | Customer purchase order number reference. | |||||
Customer purchase order number reference. |
||||||||
10 | AccountNumber | nvarchar(15) | Financial accounting number reference. | |||||
Financial accounting number reference. |
||||||||
11 | CustomerID | int | Sales.Customer | Customer identification number. Foreign key to Customer.BusinessEntityID. | ||||
Customer identification number. Foreign key to Customer.BusinessEntityID. References: Sales.Customer |
||||||||
12 | SalesPersonID | int | Sales.SalesPerson | Sales person who created the sales order. Foreign key to SalesPerson.BusinessEntityID. | ||||
Sales person who created the sales order. Foreign key to SalesPerson.BusinessEntityID. References: Sales.SalesPerson |
||||||||
13 | TerritoryID | int | Sales.SalesTerritory | Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. | ||||
Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. References: Sales.SalesTerritory |
||||||||
14 | BillToAddressID | int | Person.Address | Customer billing address. Foreign key to Address.AddressID. | ||||
Customer billing address. Foreign key to Address.AddressID. References: Person.Address |
||||||||
15 | ShipToAddressID | int | Person.Address | Customer shipping address. Foreign key to Address.AddressID. | ||||
Customer shipping address. Foreign key to Address.AddressID. References: Person.Address |
||||||||
16 | ShipMethodID | int | Purchasing.ShipMethod | Shipping method. Foreign key to ShipMethod.ShipMethodID. | ||||
Shipping method. Foreign key to ShipMethod.ShipMethodID. References: Purchasing.ShipMethod |
||||||||
17 | CreditCardID | int | Sales.CreditCard | Credit card identification number. Foreign key to CreditCard.CreditCardID. | ||||
Credit card identification number. Foreign key to CreditCard.CreditCardID. References: Sales.CreditCard |
||||||||
18 | CreditCardApprovalCode | varchar(15) | Approval code provided by the credit card company. | |||||
Approval code provided by the credit card company. |
||||||||
19 | CurrencyRateID | int | Sales.CurrencyRate | Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. | ||||
Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. References: Sales.CurrencyRate |
||||||||
20 | SubTotal | money | Default: 0.00 | Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. | ||||
Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. Default: 0.00 |
||||||||
21 | TaxAmt | money | Default: 0.00 | Tax amount. | ||||
Tax amount. Default: 0.00 |
||||||||
22 | Freight | money | Default: 0.00 | Shipping cost. | ||||
Shipping cost. Default: 0.00 |
||||||||
23 | TotalDue | money | Computed: isnull(([SubTotal]+[TaxAmt])+[Freight],(0)) | Total due from customer. Computed as Subtotal + TaxAmt + Freight. | ||||
Total due from customer. Computed as Subtotal + TaxAmt + Freight. Computed: isnull(([SubTotal]+[TaxAmt])+[Freight],(0)) |
||||||||
24 | Comment | nvarchar(128) | Sales representative comments. | |||||
Sales representative comments. |
||||||||
25 | rowguid | uniqueidentifier | Default: newid() | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. | ||||
ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Default: newid() |
||||||||
26 | ModifiedDate | datetime | Default: getdate() | Date and time the record was last updated. | ||||
Date and time the record was last updated. Default: getdate() |
Relations
Foreign table | Primary table | Join | Title / Name / Description | |
---|---|---|---|---|
Sales.SalesOrderHeader | Person.Address | Sales.SalesOrderHeader.BillToAddressID = Person.Address.AddressID | FK_SalesOrderHeader_Address_BillToAddressID Foreign key constraint referencing Address.AddressID. |
|
Sales.SalesOrderHeader.BillToAddressID = Person.Address.AddressID Name: FK_SalesOrderHeader_Address_BillToAddressIDForeign key constraint referencing Address.AddressID. |
||||
Sales.SalesOrderHeader | Person.Address | Sales.SalesOrderHeader.ShipToAddressID = Person.Address.AddressID | FK_SalesOrderHeader_Address_ShipToAddressID Foreign key constraint referencing Address.AddressID. |
|
Sales.SalesOrderHeader.ShipToAddressID = Person.Address.AddressID Name: FK_SalesOrderHeader_Address_ShipToAddressIDForeign key constraint referencing Address.AddressID. |
||||
Sales.SalesOrderHeader | Sales.CreditCard | Sales.SalesOrderHeader.CreditCardID = Sales.CreditCard.CreditCardID | FK_SalesOrderHeader_CreditCard_CreditCardID Foreign key constraint referencing CreditCard.CreditCardID. |
|
Sales.SalesOrderHeader.CreditCardID = Sales.CreditCard.CreditCardID Name: FK_SalesOrderHeader_CreditCard_CreditCardIDForeign key constraint referencing CreditCard.CreditCardID. |
||||
Sales.SalesOrderHeader | Sales.CurrencyRate | Sales.SalesOrderHeader.CurrencyRateID = Sales.CurrencyRate.CurrencyRateID | FK_SalesOrderHeader_CurrencyRate_CurrencyRateID Foreign key constraint referencing CurrencyRate.CurrencyRateID. |
|
Sales.SalesOrderHeader.CurrencyRateID = Sales.CurrencyRate.CurrencyRateID Name: FK_SalesOrderHeader_CurrencyRate_CurrencyRateIDForeign key constraint referencing CurrencyRate.CurrencyRateID. |
||||
Sales.SalesOrderHeader | Sales.Customer | Sales.SalesOrderHeader.CustomerID = Sales.Customer.CustomerID | FK_SalesOrderHeader_Customer_CustomerID Foreign key constraint referencing Customer.CustomerID. |
|
Sales.SalesOrderHeader.CustomerID = Sales.Customer.CustomerID Name: FK_SalesOrderHeader_Customer_CustomerIDForeign key constraint referencing Customer.CustomerID. |
||||
Sales.SalesOrderHeader | Sales.SalesPerson | Sales.SalesOrderHeader.SalesPersonID = Sales.SalesPerson.BusinessEntityID | FK_SalesOrderHeader_SalesPerson_SalesPersonID Foreign key constraint referencing SalesPerson.SalesPersonID. |
|
Sales.SalesOrderHeader.SalesPersonID = Sales.SalesPerson.BusinessEntityID Name: FK_SalesOrderHeader_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID. |
||||
Sales.SalesOrderHeader | Sales.SalesTerritory | Sales.SalesOrderHeader.TerritoryID = Sales.SalesTerritory.TerritoryID | FK_SalesOrderHeader_SalesTerritory_TerritoryID Foreign key constraint referencing SalesTerritory.TerritoryID. |
|
Sales.SalesOrderHeader.TerritoryID = Sales.SalesTerritory.TerritoryID Name: FK_SalesOrderHeader_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID. |
||||
Sales.SalesOrderHeader | Purchasing.ShipMethod | Sales.SalesOrderHeader.ShipMethodID = Purchasing.ShipMethod.ShipMethodID | FK_SalesOrderHeader_ShipMethod_ShipMethodID Foreign key constraint referencing ShipMethod.ShipMethodID. |
|
Sales.SalesOrderHeader.ShipMethodID = Purchasing.ShipMethod.ShipMethodID Name: FK_SalesOrderHeader_ShipMethod_ShipMethodIDForeign key constraint referencing ShipMethod.ShipMethodID. |
||||
Sales.SalesOrderDetail | Sales.SalesOrderHeader | Sales.SalesOrderDetail.SalesOrderID = Sales.SalesOrderHeader.SalesOrderID | FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID Foreign key constraint referencing SalesOrderHeader.PurchaseOrderID. |
|
Sales.SalesOrderDetail.SalesOrderID = Sales.SalesOrderHeader.SalesOrderID Name: FK_SalesOrderDetail_SalesOrderHeader_SalesOrderIDForeign key constraint referencing SalesOrderHeader.PurchaseOrderID. |
||||
Sales.SalesOrderHeaderSalesReason | Sales.SalesOrderHeader | Sales.SalesOrderHeaderSalesReason.SalesOrderID = Sales.SalesOrderHeader.SalesOrderID | FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID Foreign key constraint referencing SalesOrderHeader.SalesOrderID. |
|
Sales.SalesOrderHeaderSalesReason.SalesOrderID = Sales.SalesOrderHeader.SalesOrderID Name: FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderIDForeign key constraint referencing SalesOrderHeader.SalesOrderID. |
Unique keys
Key name | Columns | Description | |
---|---|---|---|
PK_SalesOrderHeader_SalesOrderID | SalesOrderID | Primary key (clustered) constraint | |
Primary key (clustered) constraint | |||
AK_SalesOrderHeader_rowguid | rowguid | Unique nonclustered index. Used to support replication samples. | |
Unique nonclustered index. Used to support replication samples. | |||
AK_SalesOrderHeader_SalesOrderNumber | SalesOrderNumber | Unique nonclustered index. | |
Unique nonclustered index. |
Triggers
Key name | When | Description | |
---|---|---|---|
uSalesOrderHeader | After Update | AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. | |
AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. |
Uses
Name |
---|
Sales.SalesOrderHeader
|
Sales.SalesOrderHeader
|
Sales.uSalesOrderHeader
|
Sales.SalesOrderHeader
|
Used by
Name |
---|
Sales.SalesOrderHeader
|
Sales.SalesOrderHeader
|
Sales.uSalesOrderHeader
|
Exported: 2019-02-04 23:13, Last imported: 2018-03-07 11:56