AdventureWorks
Sales.SalesOrderHeaderSalesReason Table
Description
Cross-reference table mapping sales orders to sales reason codes.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File Group
System Object
Published for Replication
Rows27647
Data Space Used688.00 KB
Index Space Used16.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key SalesOrderIDPrimary key. Foreign key to SalesOrderHeader.SalesOrderID.int4   
Primary Key SalesReasonIDPrimary key. Foreign key to SalesReason.SalesReasonID.int4   
 ModifiedDateDate and time the record was last updated.datetime4 
(getdate())
 
Indexes
IndexDescriptionPrimaryUnique
PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonIDPrimary key (clustered) constraint
Relationships
RelationshipDescription
FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderIDForeign key constraint referencing SalesOrderHeader.SalesOrderID.
FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonIDForeign key constraint referencing SalesReason.SalesReasonID.
Objects that Sales.SalesOrderHeaderSalesReason depends on
 Database ObjectObject TypeDescriptionDep Level
dbo.AccountNumber datatypedbo.AccountNumberUser Defined Data Type 2
Person.Address tablePerson.AddressTableStreet address information for customers, employees, and vendors.2
Person.Contact tablePerson.ContactTableNames of each employee, customer contact, and vendor contact.2
Person.CountryRegion tablePerson.CountryRegionTableLookup table containing the ISO standard codes for countries and regions.4
Sales.CreditCard tableSales.CreditCardTableCustomer credit card information.2
Sales.Currency tableSales.CurrencyTableLookup table containing standard ISO currencies.3
Sales.CurrencyRate tableSales.CurrencyRateTableCurrency exchange rates.2
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Individual and Store tables.2
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.3
dbo.ErrorLog tabledbo.ErrorLogTableAudit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct.3
dbo.Flag datatypedbo.FlagUser Defined Data Type 2
dbo.Name datatypedbo.NameUser Defined Data Type 2
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 3
dbo.OrderNumber datatypedbo.OrderNumberUser Defined Data Type 2
dbo.Phone datatypedbo.PhoneUser Defined Data Type 3
Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.1
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.2
Sales.SalesReason tableSales.SalesReasonTableLookup table of customer purchase reasons.1
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.2
Purchasing.ShipMethod tablePurchasing.ShipMethodTableShipping company lookup table.2
Person.StateProvince tablePerson.StateProvinceTableState and province lookup table.3
dbo.ufnGetAccountingEndDate functiondbo.ufnGetAccountingEndDateUser Defined FunctionScalar function used in the uSalesOrderHeader trigger to set the starting account date.2
dbo.ufnGetAccountingStartDate functiondbo.ufnGetAccountingStartDateUser Defined FunctionScalar function used in the uSalesOrderHeader trigger to set the ending account date.2
dbo.ufnLeadingZeros functiondbo.ufnLeadingZerosUser Defined FunctionScalar function used by the Sales.Customer table to help set the account number.3
dbo.uspLogError proceduredbo.uspLogErrorStored ProcedureLogs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information.2
dbo.uspPrintError proceduredbo.uspPrintErrorStored ProcedurePrints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information.2
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Sales].[SalesOrderHeaderSalesReason](
	[SalesOrderID] [int] NOT NULL,
	[SalesReasonID] [int] NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonID] PRIMARY KEY CLUSTERED 
(
	[SalesOrderID] ASC,
	[SalesReasonID] 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].[SalesOrderHeaderSalesReason]  WITH CHECK ADD  CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID] FOREIGN KEY([SalesOrderID])
REFERENCES [SalesOrderHeader] ([SalesOrderID])
ON DELETE CASCADE
ALTER TABLE [Sales].[SalesOrderHeaderSalesReason] CHECK CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]
ALTER TABLE [Sales].[SalesOrderHeaderSalesReason]  WITH CHECK ADD  CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID] FOREIGN KEY([SalesReasonID])
REFERENCES [SalesReason] ([SalesReasonID])
ALTER TABLE [Sales].[SalesOrderHeaderSalesReason] CHECK CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]
ALTER TABLE [Sales].[SalesOrderHeaderSalesReason] ADD  CONSTRAINT [DF_SalesOrderHeaderSalesReason_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
See Also

Related Objects

Sales Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.