Properties

Owner: Sales 
Creation Date: 04/26/2006 
Located On: PRIMARY 
Data Size KB: 9864 
Index Size KB: 5144 
Rows: 121317 
Description: Individual products associated with a specific sales order. See SalesOrderHeader. 

Columns

Name Data Type Length NULL Default IsIdentity IsGUID Description
    SalesOrderID  int          Primary key. Foreign key to SalesOrderHeader.SalesOrderID. 
    SalesOrderDetailID  int          Primary key. One incremental unique number per product sold. 
    CarrierTrackingNumber  nvarchar  25          Shipment tracking number supplied by the shipper. 
    OrderQty  smallint          Quantity ordered per product. 
    ProductID  int          Product sold to customer. Foreign key to Product.ProductID. 
    SpecialOfferID  int          Promotional code. Foreign key to SpecialOffer.SpecialOfferID. 
    UnitPrice  money          Selling price of a single product. 
    UnitPriceDiscount  money    ((0.0))      Discount amount. 
    LineTotal  numeric  17          Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty. 
    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: 11 column(s)

Identity column

Name Seed Increment Not for replication
  SalesOrderDetailID   

Indexes

Index Primary Unique Description
  PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID      Primary key (clustered) constraint 
  IX_SalesOrderDetail_ProductID      Nonclustered index. 
  AK_SalesOrderDetail_rowguid      Unique nonclustered index. Used to support replication samples. 
Total: 3 index(es)

Triggers

Name Owner Instead Of Disabled Table/View Description
  iduSalesOrderDetail  Sales      Sales.SalesOrderDetail  AFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column. 
Total: 1 trigger(s)

Check Constraints

Name Expression
  CK_SalesOrderDetail_OrderQty  ([OrderQty]>(0)) 
  CK_SalesOrderDetail_UnitPrice  ([UnitPrice]>=(0.00)) 
  CK_SalesOrderDetail_UnitPriceDiscount  ([UnitPriceDiscount]>=(0.00)) 
Total: 3 constraint(s)

Referenced Tables

Table Foreign Key Primary Key or Unique Constraint
  Sales.SalesOrderHeader  FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID  PK_SalesOrderHeader_SalesOrderID 
  Sales.SpecialOfferProduct  FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID  PK_SpecialOfferProduct_SpecialOfferID_ProductID 
Total: 2 table(s)

Objects that [Sales].[SalesOrderDetail] 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 
  ProductCategory  Production  Table 
  ProductModel  Production  Table 
  SalesTerritory  Sales  Table 
  ShipMethod  Purchasing  Table 
  SpecialOffer  Sales  Table 
  UnitMeasure  Production  Table 
  CurrencyRate  Sales  Table 
  Customer  Sales  Table 
  Employee  HumanResources  Table 
  ProductSubcategory  Production  Table 
  StateProvince  Person  Table 
  Address  Person  Table 
  Product  Production  Table 
  SalesPerson  Sales  Table 
  SalesOrderHeader  Sales  Table 
  SpecialOfferProduct  Sales  Table 
Total: 27 object(s)

Objects that depend on [Sales].[SalesOrderDetail]

Object Name Owner Object Type Dep Level
  iduSalesOrderDetail  Sales  Trigger 
Total: 1 object(s)

SQL

CREATE TABLE [SalesOrderDetail] (
    [SalesOrderID] [int] NOT NULL ,
    [SalesOrderDetailID] [int] IDENTITY (1, 1) NOT NULL ,
    [CarrierTrackingNumber] [nvarchar] (25) COLLATE Latin1_General_CS_AS NULL ,
    [OrderQty] [smallint] NOT NULL ,
    [ProductID] [int] NOT NULL ,
    [SpecialOfferID] [int] NOT NULL ,
    [UnitPrice] [money] NOT NULL ,
    [UnitPriceDiscount] [money] NOT NULL CONSTRAINT [DF_SalesOrderDetail_UnitPriceDiscount] DEFAULT ((0.0)),
    [LineTotal] AS (isnull(([UnitPrice]*((1.0)-[UnitPriceDiscount]))*[OrderQty],(0.0))) ,
    [rowguid]  uniqueidentifier ROWGUIDCOL  NOT NULL CONSTRAINT [DF_SalesOrderDetail_rowguid] DEFAULT (newid()),
    [ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderDetail_ModifiedDate] DEFAULT (getdate()),
    CONSTRAINT [PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID] PRIMARY KEY  CLUSTERED
    (
        [SalesOrderID],
        [SalesOrderDetailID]
    )  ON [PRIMARY] ,
    CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID] FOREIGN KEY
    (
        [SalesOrderID]
    ) REFERENCES [SalesOrderHeader] (
        [SalesOrderID]
    ) ON DELETE CASCADE ,
    CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID] FOREIGN KEY
    (
        [SpecialOfferID],
        [ProductID]
    ) REFERENCES [SpecialOfferProduct] (
        [SpecialOfferID],
        [ProductID]
    ),
    CONSTRAINT [CK_SalesOrderDetail_OrderQty] CHECK ([OrderQty]>(0)),
    CONSTRAINT [CK_SalesOrderDetail_UnitPrice] CHECK ([UnitPrice]>=(0.00)),
    CONSTRAINT [CK_SalesOrderDetail_UnitPriceDiscount] CHECK ([UnitPriceDiscount]>=(0.00))
) ON [PRIMARY]
GO


See Also

List of tables