Parameters

Seq 0 Time 10 Database 20 Procedure Filter 30 Function Filter 40 Table Filter 50 View Filter 60 Trigger Filter 70 Index Filter Parameter Name AdventureWorks % % % % % % Parameter Value Dec 24 2008 2:35:36:560PM

Dashboards

Object Distribution

Object Distribution
14% Views=17 9% Functions=11 8% Procedures=9 9% Triggers=11

59% Tables=70

Functions

Procedures

Tables

Triggers

Views

Top Tables by Rows

Top Tables by Rows
121317

120,000 110,000 100,000 90,000

113443

89253

Row Count

80,000 70,000 60,000 50,000 40,000

72591 67131

31465

30,000 20,000 10,000 0

27647 19972 19614 19220 19185 19118 19118 18484 13532

l l t r r er ss ss on tai ive ac ing ua ory ate ard ard de de dre ddre stom d i t C d i t C d i v i d c y R D e H i s t A r c h rkOr R o u t H e a R e a s Cont d e r ion u r r y s rA d re re en In -A C Wo r d e tor rde tC Or ct a l e rson s o n me es - C les urr l e s a n s a n H i s tion - o r k O l e s O e r S tac les l r sto -C e a d P o Sa les Sa C o n S a Pe - Cu -S W Tr Sa uc ea cti Sa sl e s i o n - a n s a Prod i o n - l e s - d e r H es l ale S a uct r r a ct Sa S T S O u od od ion les Pr Pr Sa ct u od les Pr Sa

Tables rows

Top Tables by Size

Top Tables by Size
25,000 22,500 20,000 17,500 15,000
15008 24704

Y

12,500 10,000 7,500 5,000 2,500 0
9296 7976 7312 6456 6432 5888 4664 2272 2256 2000

1432

1416

1168

l l t r r r y s s d o g te tai ua d e c h i v e u t i n g ntac tor rde d r e s i t C a r P h o t t o m e s e L o res yRa r o o i v i d e r D e nHis r H e a t dd d kO s c d a d n A rR e yA uc - Cu - C Wor erA tab Cr - I n s O r d actio O r d e istor rre od nr d e son D a stom - Cu Pr ales ss r ns le les H kO rso n r a le n le u oPe uctio Sa S Pe S a ction -S Tra - S a actio - Wo les db s - C od Sa e s ion s u r le n d on al les P o ti t S ra Sa Sa Pr uc - T oduc r rod on P P ti uc rod P

X Size_in_KB

Tables
Table Name AWBuildVersion DatabaseLog ErrorLog Department Employee EmployeeAddress EmployeeDepartmentHistory EmployeePayHistory JobCandidate Shift Address AddressType Contact ContactType CountryRegion StateProvince BillOfMaterials Culture Document Illustration Location Product ProductCategory ProductCostHistory dbo dbo dbo HumanResources HumanResources HumanResources HumanResources HumanResources HumanResources HumanResources Person Person Person Person Person Person Production Production Production Production Production Production Production Production Table Schema

Table Name ProductDescription ProductDocument ProductInventory ProductListPriceHistory ProductModel ProductModelIllustration ProductModelProductDescriptionCulture ProductPhoto ProductProductPhoto ProductReview ProductSubcategory ScrapReason TransactionHistory TransactionHistoryArchive UnitMeasure WorkOrder WorkOrderRouting ProductVendor PurchaseOrderDetail PurchaseOrderHeader ShipMethod Vendor VendorAddress VendorContact ContactCreditCard Production Production Production Production Production Production Production Production Production Production Production Production Production Production Production Production Production Purchasing Purchasing Purchasing Purchasing Purchasing Purchasing Purchasing Sales

Table Schema

Table Name CountryRegionCurrency CreditCard Currency CurrencyRate Customer CustomerAddress Individual SalesOrderDetail SalesOrderHeader SalesOrderHeaderSalesReason SalesPerson SalesPersonQuotaHistory SalesReason SalesTaxRate SalesTerritory SalesTerritoryHistory ShoppingCartItem SpecialOffer SpecialOfferProduct Store StoreContact Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales Sales

Table Schema

AWBuildVersion
Column Details Column Name Database Version ModifiedDate SystemInformationID SystemInformationID VersionDate Data Type nvarchar datetime tinyint tinyint datetime Length 25 (getdate()) Column Default Is Nullable NO NO NO NO NO Description Version number of the database in 9.yy.mm.dd.00 format. Date and time the record was last updated. Primary key for AWBuildVersion records. Clustered index created by a primary key constraint. Date and time the record was last updated.

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

AWBuildVersi PK_AWBuildVersion_Sy SystemInformatio CLUSTERED on stemInformationID nID

Dependent Objects ---None---

DatabaseLog
Column Details Column Name DatabaseLogID int Data Type Length Column Default Is Nullable NO Description Primary key for DatabaseLog records.

Column Name DatabaseUser Event Object PostTime PostTime Schema TSQL XmlEvent

Data Type nvarchar nvarchar nvarchar datetime datetime nvarchar nvarchar xml

Length 128 128 128

Column Default

Is Nullable NO NO YES NO NO

Description The user who implemented the DDL change. The type of DDL statement that was executed. The object that was changed by the DDL statment. The date and time the DDL change occurred. Nonclustered index created by a primary key constraint. The schema to which the changed object belongs. The exact Transact-SQL statement that was executed. The raw XML data generated by database trigger.

128 -1 -1

YES NO NO

Table Indexes Table Name Index Name Column Name Index Type NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

DatabaseLog PK_DatabaseLog_Datab DatabaseLogID aseLogID

Dependent Objects ---None---

ErrorLog
Column Details Column Name ErrorLine ErrorLogID ErrorLogID ErrorMessage ErrorNumber ErrorProcedure ErrorSeverity ErrorState ErrorTime UserName int int int nvarchar int nvarchar int int datetime nvarchar 128 (getdate()) 126 4000 Data Type Length Column Default Is Nullable YES NO NO NO NO YES YES YES NO NO Description The line number at which the error occurred. Primary key for ErrorLog records. Clustered index created by a primary key constraint. The message text of the error that occurred. The error number of the error that occurred. The name of the stored procedure or trigger where the error occurred. The severity of the error that occurred. The state number of the error that occurred. The date and time at which the error occurred. The user who executed the batch in which the error occurred.

Table Indexes Table Name ErrorLog Index Name Column Name Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false Index Type

PK_ErrorLog_ErrorLogID ErrorLogID

Dependent Objects Dependent Obj uspLogError SQL_STORED_PROCEDURE Dependent Obj Type

Department
Column Details Column Name DepartmentID DepartmentID GroupName ModifiedDate Name Name Data Type smallint smallint nvarchar datetime nvarchar nvarchar 50 50 50 (getdate()) Length Column Default Is Nullable NO NO NO NO NO NO Description Primary key for Department records. Clustered index created by a primary key constraint. Name of the group to which the department belongs. Date and time the record was last updated. Name of the department. Unique nonclustered index.

Table Indexes Table Name Department Department Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_Department_Depart DepartmentID mentID AK_Department_Name Name

Dependent Objects Dependent Obj vEmployeeDepartment VIEW Dependent Obj Type

Dependent Obj vEmployeeDepartmentHistory VIEW

Dependent Obj Type

Employee
Column Details Column Name BirthDate ContactID ContactID CurrentFlag EmployeeID EmployeeID Gender HireDate LoginID LoginID ManagerID ManagerID MaritalStatus ModifiedDate NationalIDNumber NationalIDNumber Data Type datetime int int bit int int nchar datetime nvarchar nvarchar int int nchar datetime nvarchar nvarchar 15 15 1 (getdate()) 256 256 1 ((1)) Length Column Default Is Nullable NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO NO Description Date of birth. Identifies the employee in the Contact table. Foreign key to Contact.ContactID. Unique nonclustered index. 0 = Inactive, 1 = Active Primary key for Employee records. Clustered index created by a primary key constraint. M = Male, F = Female Employee hired on this date. Network login. Unique nonclustered index. Used to support replication samples. Manager to whom the employee is assigned. Foreign Key to Employee.M Nonclustered index. M = Married, S = Single Date and time the record was last updated. Unique national identification number such as a social security number. Unique nonclustered index.

Column Name rowguid SalariedFlag SickLeaveHours Title VacationHours

Data Type uniqueidentifier bit smallint nvarchar smallint

Length

Column Default (newid()) ((1)) ((0)) 50 ((0))

Is Nullable NO NO NO NO NO

Description ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. Number of available sick leave hours. Work title such as Buyer or Sales Representative. Number of available vacation hours.

Table Indexes Table Name Employee Employee Employee Employee Employee Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false true false false false false false false false false false false false false false false Is Padded false false false false false Is Hypothetical false false false false false

PK_Employee_Employe EmployeeID eID AK_Employee_LoginID LoginID

NONCLUSTE RED AK_Employee_NationalI NationalIDNumbe NONCLUSTE DNumber r RED NONCLUSTE AK_Employee_rowguid rowguid RED IX_Employee_ManagerI ManagerID NONCLUSTE D RED

Dependent Objects

Dependent Obj uspGetEmployeeManagers uspGetManagerEmployees uspUpdateEmployeeHireInfo uspUpdateEmployeeLogin uspUpdateEmployeePersonalInfo ufnGetContactInformation vEmployee vEmployeeDepartment vEmployeeDepartmentHistory vSalesPerson vSalesPersonSalesByFiscalYears SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE

Dependent Obj Type

SQL_TABLE_VALUED_FUNCTION VIEW VIEW VIEW VIEW VIEW

EmployeeAddress
Column Details Column Name AddressID AddressID EmployeeID EmployeeID ModifiedDate int int int int datetime (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO Description Primary key. Foreign key to Address.AddressID. Unique nonclustered index. Used to support replication samples. Primary key. Foreign key to Employee.EmployeeID. Clustered index created by a primary key constraint. Date and time the record was last updated.

Column Name rowguid

Data Type uniqueidentifier

Length

Column Default (newid())

Is Nullable NO

Description ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

Table Indexes Table Name EmployeeAdd ress EmployeeAdd ress EmployeeAdd ress Index Name Column Name Index Type CLUSTERED CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true false false false false false false false Is Padded false false false Is Hypothetical false false false

PK_EmployeeAddress_E EmployeeID mployeeID_AddressID PK_EmployeeAddress_E AddressID mployeeID_AddressID AK_EmployeeAddress_r rowguid owguid

Dependent Objects Dependent Obj vEmployee vSalesPerson VIEW VIEW Dependent Obj Type

EmployeeDepartmentHistory
Column Details

Column Name DepartmentID DepartmentID EmployeeID EmployeeID EndDate ModifiedDate ShiftID ShiftID StartDate

Data Type smallint smallint int int datetime datetime tinyint tinyint datetime

Length

Column Default

Is Nullable NO NO NO NO YES

Description Department in which the employee worked including currently. Foreign key to Department.DepartmentID. Nonclustered index. Employee identification number. Foreign key to Employee.EmployeeID. Clustered index created by a primary key constraint. Date the employee left the department. NULL = Current department. Date and time the record was last updated. Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID. Nonclustered index. Date the employee started work in the department.

(getdate())

NO NO NO NO

Table Indexes Table Name EmployeeDep artmentHistor y EmployeeDep artmentHistor y EmployeeDep artmentHistor y Index Name Column Name Index Type CLUSTERED CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true true false false false false false false Is Padded false false false Is Hypothetical false false false

PK_EmployeeDepartmen tHistory_EmployeeID_St EmployeeID artDate_DepartmentID PK_EmployeeDepartmen tHistory_EmployeeID_St DepartmentID artDate_DepartmentID PK_EmployeeDepartmen tHistory_EmployeeID_St ShiftID artDate_DepartmentID

Table Name EmployeeDep artmentHistor y EmployeeDep artmentHistor y EmployeeDep artmentHistor y

Index Name

Column Name

Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false true false false false false false false false false

Is Padded false false false

Is Hypothetical false false false

PK_EmployeeDepartmen tHistory_EmployeeID_St StartDate artDate_DepartmentID IX_EmployeeDepartment DepartmentID History_DepartmentID IX_EmployeeDepartment ShiftID History_ShiftID

Dependent Objects Dependent Obj vEmployeeDepartment vEmployeeDepartmentHistory VIEW VIEW Dependent Obj Type

EmployeePayHistory
Column Details Column Name EmployeeID EmployeeID ModifiedDate PayFrequency int int datetime tinyint (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO Description Employee identification number. Foreign key to Employee.EmployeeID. Clustered index created by a primary key constraint. Date and time the record was last updated. 1 = Salary received monthly, 2 = Salary received biweekly

Column Name Rate RateChangeDate

Data Type money datetime

Length

Column Default

Is Nullable NO NO

Description Salary hourly rate. Date the change in pay is effective

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

EmployeePay PK_EmployeePayHistory EmployeeID _EmployeeID_RateChan CLUSTERED History geDate EmployeePay PK_EmployeePayHistory RateChangeDate CLUSTERED _EmployeeID_RateChan History geDate

Dependent Objects Dependent Obj uspUpdateEmployeeHireInfo SQL_STORED_PROCEDURE Dependent Obj Type

JobCandidate
Column Details Column Name EmployeeID int Data Type Length Column Default Is Nullable YES Description Employee identification number if applicant was hired. Foreign key to Employee.EmployeeID.

Column Name EmployeeID JobCandidateID JobCandidateID ModifiedDate Resume int int int

Data Type

Length

Column Default

Is Nullable YES NO NO

Description Nonclustered index. Primary key for JobCandidate records. Clustered index created by a primary key constraint. Date and time the record was last updated. Résumé in XML format.

datetime xml -1

(getdate())

NO YES

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true false true false false false false false Is Padded false false Is Hypothetical false false

JobCandidate PK_JobCandidate_JobC JobCandidateID andidateID JobCandidate IX_JobCandidate_Emplo EmployeeID yeeID

Dependent Objects Dependent Obj vJobCandidate vJobCandidateEducation vJobCandidateEmployment VIEW VIEW VIEW Dependent Obj Type

Shift
Column Details Column Name EndTime ModifiedDate Name Name ShiftID ShiftID StartTime StartTime Data Type datetime datetime nvarchar nvarchar tinyint tinyint datetime datetime 50 50 (getdate()) Length Column Default Is Nullable NO NO NO NO NO NO NO NO Shift end time. Date and time the record was last updated. Shift description. Unique nonclustered index. Primary key for Shift records. Clustered index created by a primary key constraint. Shift start time. Unique nonclustered index. Description

Table Indexes Table Name Shift Shift Shift Shift Index Name PK_Shift_ShiftID AK_Shift_Name Column Name ShiftID Name Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED NONCLUSTE true false false false false false RED NONCLUSTE true false false false false false RED Index Type

AK_Shift_StartTime_End StartTime Time AK_Shift_StartTime_End EndTime Time

Dependent Objects

Dependent Obj vEmployeeDepartmentHistory VIEW

Dependent Obj Type

Address
Column Details Column Name AddressID AddressID AddressLine1 AddressLine1 AddressLine2 AddressLine2 City City ModifiedDate PostalCode rowguid StateProvinceID int int nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar datetime nvarchar uniqueidentifier int 15 (newid()) 60 60 60 60 30 30 (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO YES YES NO NO NO NO NO NO Description Primary key for Address records. Clustered index created by a primary key constraint. First street address line. Unique nonclustered index. Used to support replication samples. Second street address line. Nonclustered index. Name of the city. Nonclustered index. Date and time the record was last updated. Postal code for the street address. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Unique identification number for the state or province. Foreign key to StateProvince table.

Table Indexes

Table Name Address Address Address

Index Name

Column Name

PK_Address_AddressID AddressID AK_Address_rowguid IX_Address_AddressLine 1_AddressLine2_City_St ateProvinceID_PostalCo de IX_Address_AddressLine 1_AddressLine2_City_St ateProvinceID_PostalCo de IX_Address_AddressLine 1_AddressLine2_City_St ateProvinceID_PostalCo de IX_Address_AddressLine 1_AddressLine2_City_St ateProvinceID_PostalCo de IX_Address_AddressLine 1_AddressLine2_City_St ateProvinceID_PostalCo de IX_Address_StateProvin ceID rowguid AddressLine1

Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED Index Type NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED true false false false false false

Address

AddressLine2

true

false

false

false

false

false

Address

City

true

false

false

false

false

false

Address

StateProvinceID

true

false

false

false

false

false

Address Address

PostalCode StateProvinceID

true false

false false

false false

false false

false false

false false

Dependent Objects Dependent Obj vEmployee vIndividualCustomer VIEW VIEW Dependent Obj Type

Dependent Obj vSalesPerson vStoreWithDemographics vVendor VIEW VIEW VIEW

Dependent Obj Type

AddressType
Column Details Column Name AddressTypeID AddressTypeID ModifiedDate Name Name rowguid rowguid int int datetime nvarchar nvarchar uniqueidentifier uniqueidentifier 50 50 (newid()) (newid()) (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO NO NO Description Primary key for AddressType records. Clustered index created by a primary key constraint. Date and time the record was last updated. Address type description. For example, Billing, Home, or Shipping. Unique nonclustered index. Used to support replication samples. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Unique nonclustered index.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

AddressType PK_AddressType_Addre AddressTypeID ssTypeID

Table Name

Index Name

Column Name

Index Type NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false false false false false

Is Padded false false

Is Hypothetical false false

AddressType AK_AddressType_rowgui rowguid d AddressType AK_AddressType_Name Name

Dependent Objects Dependent Obj vIndividualCustomer vStoreWithDemographics VIEW VIEW Dependent Obj Type

Contact
Column Details Column Name AdditionalContactInfo ContactID ContactID EmailAddress xml int int nvarchar 50 Data Type Length -1 Column Default Is Nullable YES NO NO YES Description Additional contact information about the person stored in xml format. Primary key for Contact records. Clustered index created by a primary key constraint. E-mail address for the person. 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners.

EmailPromotion

int

((0))

NO

Column Name FirstName LastName MiddleName ModifiedDate NameStyle NameStyle PasswordHash PasswordSalt Phone rowguid Suffix Title Title

Data Type nvarchar nvarchar nvarchar datetime bit bit varchar varchar nvarchar uniqueidentifier nvarchar nvarchar nvarchar

Length 50 50 50

Column Default

Is Nullable NO NO YES

Description First name of the person. Last name of the person. Middle name or middle initial of the person. Date and time the record was last updated. 0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order. Unique nonclustered index. Used to support replication samples. Password for the e-mail account. Random value concatenated with the password string before the password is hashed. Phone number associated with the person. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Surname suffix. For example, Sr. or Jr. A courtesy title. For example, Mr. or Ms. Nonclustered index.

(getdate()) ((0)) ((0)) 128 10 25 (newid()) 10 8 8

NO NO NO NO NO YES NO YES YES YES

Table Indexes Table Name Contact Index Name PK_Contact_ContactID Column Name ContactID Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false Index Type

Table Name Contact Contact Contact

Index Name AK_Contact_rowguid

Column Name rowguid

Index Type NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false false false false false false false false false

Is Padded false false false

Is Hypothetical false false false

IX_Contact_EmailAddres EmailAddress s PXML_Contact_AddCont AdditionalContact XML act Info

Dependent Objects Dependent Obj uspGetEmployeeManagers uspGetManagerEmployees ufnGetContactInformation vAdditionalContactInfo vEmployee vEmployeeDepartment vEmployeeDepartmentHistory vIndividualCustomer vSalesPerson vSalesPersonSalesByFiscalYears vStoreWithDemographics vVendor SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_TABLE_VALUED_FUNCTION VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW Dependent Obj Type

ContactType
Column Details Column Name ContactTypeID ContactTypeID ModifiedDate Name Name int int datetime nvarchar nvarchar 50 50 (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO Description Primary key for ContactType records. Clustered index created by a primary key constraint. Date and time the record was last updated. Contact type description. Unique nonclustered index.

Table Indexes Table Name ContactType ContactType Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_ContactType_Contac ContactTypeID tTypeID AK_ContactType_Name Name

Dependent Objects Dependent Obj ufnGetContactInformation vStoreWithDemographics vVendor VIEW VIEW Dependent Obj Type SQL_TABLE_VALUED_FUNCTION

CountryRegion
Column Details Column Name CountryRegionCode CountryRegionCode ModifiedDate Name Name Data Type nvarchar nvarchar datetime nvarchar nvarchar 50 50 Length 3 3 (getdate()) Column Default Is Nullable NO NO NO NO NO Description ISO standard code for countries and regions. Clustered index created by a primary key constraint. Date and time the record was last updated. Country or region name. Unique nonclustered index.

Table Indexes Table Name CountryRegio n CountryRegio n Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_CountryRegion_Cou CountryRegionCo CLUSTERED ntryRegionCode de AK_CountryRegion_Nam Name NONCLUSTE e RED

Dependent Objects Dependent Obj vEmployee vIndividualCustomer vSalesPerson vStateProvinceCountryRegion vStoreWithDemographics VIEW VIEW VIEW VIEW VIEW Dependent Obj Type

Dependent Obj vVendor VIEW

Dependent Obj Type

StateProvince
Column Details Column Name CountryRegionCode CountryRegionCode IsOnlyStateProvinceFlag IsOnlyStateProvinceFlag ModifiedDate Name rowguid StateProvinceCode StateProvinceCode StateProvinceID StateProvinceID TerritoryID Data Type nvarchar nvarchar bit bit datetime nvarchar uniqueidentifier nchar nchar int int int 3 3 50 (newid()) Length 3 3 ((1)) ((1)) (getdate()) Column Default Is Nullable NO NO NO NO NO NO NO NO NO NO NO NO Description ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. Unique nonclustered index. 0 = StateProvinceCode exists. 1 = StateProvinceCode unavailable, using CountryRegionCode. Unique nonclustered index. Used to support replication samples. Date and time the record was last updated. State or province description. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. ISO standard state or province code. Unique nonclustered index. Primary key for StateProvince records. Clustered index created by a primary key constraint. ID of the territory in which the state or province is located. Foreign key to SalesTerritory.SalesTerritoryID.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true true false false false false false false false false false false false false false false Is Padded false false false false false Is Hypothetical false false false false false

StateProvince PK_StateProvince_State StateProvinceID ProvinceID StateProvince AK_StateProvince_Nam Name e AK_StateProvince_State StateProvince ProvinceCode_CountryR StateProvinceCo de egionCode AK_StateProvince_State StateProvince ProvinceCode_CountryR CountryRegionCo de egionCode StateProvince AK_StateProvince_rowg rowguid uid

Dependent Objects Dependent Obj vEmployee vIndividualCustomer vSalesPerson vStateProvinceCountryRegion vStoreWithDemographics vVendor VIEW VIEW VIEW VIEW VIEW VIEW Dependent Obj Type

BillOfMaterials
Column Details

Column Name BillOfMaterialsID BillOfMaterialsID BOMLevel ComponentID ComponentID EndDate ModifiedDate PerAssemblyQty ProductAssemblyID ProductAssemblyID StartDate UnitMeasureCode int int

Data Type

Length

Column Default

Is Nullable NO NO NO NO NO YES

Description Primary key for BillOfMaterials records. Clustered index. Indicates the depth the component is from its parent (AssemblyID). Component identification number. Foreign key to Product.ProductID. Nonclustered index. Date the component stopped being used in the assembly item. Date and time the record was last updated. Quantity of the component needed to create the assembly. Parent product identification number. Foreign key to Product.ProductID. Nonclustered index created by a primary key constraint. Date the component started being used in the assembly item. Standard code identifying the unit of measure for the quantity.

smallint int int datetime datetime decimal int int datetime nchar 3 (getdate()) (getdate()) ((1.00))

NO NO YES YES NO NO

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false false false false false Is Padded false false Is Hypothetical false false

BillOfMaterial AK_BillOfMaterials_Prod ProductAssembly CLUSTERED uctAssemblyID_Compon ID s entID_StartDate BillOfMaterial AK_BillOfMaterials_Prod ComponentID uctAssemblyID_Compon CLUSTERED s entID_StartDate

Table Name

Index Name

Column Name

Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false true false false false false false false false

Is Padded false false false

Is Hypothetical false false false

BillOfMaterial AK_BillOfMaterials_Prod StartDate uctAssemblyID_Compon s entID_StartDate BillOfMaterial PK_BillOfMaterials_BillOf BillOfMaterialsID s MaterialsID BillOfMaterial IX_BillOfMaterials_UnitM UnitMeasureCod s easureCode e

Dependent Objects Dependent Obj uspGetBillOfMaterials uspGetWhereUsedProductID SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE Dependent Obj Type

Culture
Column Details Column Name CultureID CultureID ModifiedDate Name Name Data Type nchar nchar datetime nvarchar nvarchar 50 50 Length 6 6 (getdate()) Column Default Is Nullable NO NO NO NO NO Description Primary key for Culture records. Clustered index created by a primary key constraint. Date and time the record was last updated. Culture description. Unique nonclustered index.

Table Indexes Table Name Culture Culture Index Name PK_Culture_CultureID AK_Culture_Name Column Name CultureID Name Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED Index Type

Dependent Objects ---None---

Document
Column Details Column Name ChangeNumber Document DocumentID DocumentID DocumentSummary FileExtension FileName int varbinary int int nvarchar nvarchar nvarchar -1 8 400 -1 Data Type Length Column Default ((0)) Is Nullable NO YES NO NO YES NO NO Description Engineering change approval number. Complete document. Primary key for Document records. Clustered index created by a primary key constraint. Document abstract. File extension indicating the document type. For example, .doc or .txt. Directory path and file name of the document

Column Name ModifiedDate Revision Status Title Title

Data Type datetime nchar tinyint nvarchar nvarchar

Length

Column Default (getdate()) 5

Is Nullable NO NO NO

Description Date and time the record was last updated. Revision number of the document. 1 = Pending approval, 2 = Approved, 3 = Obsolete Title of the document. Unique nonclustered index.

50 50

NO NO

Table Indexes Table Name Document Document Document Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false false false false false Is Padded false false false Is Hypothetical false false false

PK_Document_Documen DocumentID tID AK_Document_FileName FileName _Revision AK_Document_FileName Revision _Revision

Dependent Objects ---None---

Illustration
Column Details

Column Name Diagram IllustrationID IllustrationID ModifiedDate xml int int

Data Type

Length -1

Column Default

Is Nullable YES NO NO

Description Illustrations used in manufacturing instructions. Stored as XML. Primary key for Illustration records. Clustered index created by a primary key constraint. Date and time the record was last updated.

datetime

(getdate())

NO

Table Indexes Table Name Illustration Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

PK_Illustration_Illustratio IllustrationID nID

Dependent Objects ---None---

Location
Column Details Column Name Availability CostRate Data Type decimal smallmoney Length Column Default ((0.00)) ((0.00)) Is Nullable NO NO Description Work capacity (in hours) of the manufacturing location. Standard hourly cost of the manufacturing location.

Column Name LocationID LocationID ModifiedDate Name Name

Data Type smallint smallint datetime nvarchar nvarchar

Length

Column Default

Is Nullable NO NO

Description Primary key for Location records. Clustered index created by a primary key constraint. Date and time the record was last updated. Location description. Unique nonclustered index.

(getdate()) 50 50

NO NO NO

Table Indexes Table Name Location Location Index Name Column Name Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED Index Type

PK_Location_LocationID LocationID AK_Location_Name Name

Dependent Objects ---None---

Product
Column Details Column Name Class Data Type nchar Length 2 Column Default Is Nullable YES Description H = High, M = Medium, L = Low

Column Name Color DaysToManufacture DiscontinuedDate FinishedGoodsFlag ListPrice MakeFlag MakeFlag ModifiedDate Name Name ProductID ProductID ProductLine ProductModelID ProductNumber ProductNumber ProductSubcategoryID ReorderPoint rowguid

Data Type nvarchar int datetime bit money bit bit datetime nvarchar nvarchar int int nchar int nvarchar nvarchar int smallint uniqueidentifier

Length 15

Column Default

Is Nullable YES NO YES

Description Product color. Number of days required to manufacture the product. Date the product was discontinued. 0 = Product is not a salable item. 1 = Product is salable. Selling price. 0 = Product is purchased, 1 = Product is manufactured in-house. Unique nonclustered index. Used to support replication samples. Date and time the record was last updated. Name of the product. Unique nonclustered index. Primary key for Product records. Clustered index created by a primary key constraint. R = Road, M = Mountain, T = Touring, S = Standard Product is a member of this product model. Foreign key to ProductModel.ProductModelID. Unique product identification number. Unique nonclustered index. Product is a member of this product subcategory. Foreign key to ProductSubCategory.ProductSubCategoryID. Inventory level that triggers a purchase order or work order. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

((1))

NO NO

((1)) ((1)) (getdate()) 50 50

NO NO NO NO NO NO NO

2

YES YES

25 25

NO NO YES NO (newid()) NO

Column Name SafetyStockLevel SellEndDate SellStartDate Size SizeUnitMeasureCode StandardCost Style Weight WeightUnitMeasureCode

Data Type smallint datetime datetime nvarchar nchar money nchar decimal nchar

Length

Column Default

Is Nullable NO YES NO

Description Minimum inventory quantity. Date the product was no longer available for sale. Date the product was available for sale. Product size. Unit of measure for Size column. Standard cost of the product. W = Womens, M = Mens, U = Universal Product weight. Unit of measure for Weight column.

5 3 2 3

YES YES NO YES YES YES

Table Indexes Table Name Product Product Product Product Index Name PK_Product_ProductID AK_Product_ProductNu mber AK_Product_Name AK_Product_rowguid Column Name ProductID ProductNumber Name rowguid Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED NONCLUSTE true false false false false false RED NONCLUSTE true false false false false false RED Index Type

Dependent Objects

Dependent Obj ufnGetProductDealerPrice ufnGetProductListPrice ufnGetProductStandardCost uspGetBillOfMaterials uspGetWhereUsedProductID vProductAndDescription SQL_SCALAR_FUNCTION SQL_SCALAR_FUNCTION SQL_SCALAR_FUNCTION SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE VIEW

Dependent Obj Type

ProductCategory
Column Details Column Name ModifiedDate Name Name ProductCategoryID ProductCategoryID rowguid rowguid Data Type datetime nvarchar nvarchar int int uniqueidentifier uniqueidentifier (newid()) (newid()) 50 50 Length Column Default (getdate()) Is Nullable NO NO NO NO NO NO NO Description Date and time the record was last updated. Category description. Unique nonclustered index. Primary key for ProductCategory records. Clustered index created by a primary key constraint. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Unique nonclustered index. Used to support replication samples.

Table Indexes

Table Name ProductCateg ory ProductCateg ory ProductCateg ory

Index Name PK_ProductCategory_Pr oductCategoryID AK_ProductCategory_Na me AK_ProductCategory_ro wguid

Column Name

Index Type

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false false false false false

Is Padded false false false

Is Hypothetical false false false

ProductCategoryI CLUSTERED D NONCLUSTE Name RED NONCLUSTE rowguid RED

Dependent Objects ---None---

ProductCostHistory
Column Details Column Name EndDate ModifiedDate ProductID ProductID StandardCost StartDate Data Type datetime datetime int int money datetime (getdate()) Length Column Default Is Nullable YES NO NO NO NO NO Description Product cost end date. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID Clustered index created by a primary key constraint. Standard cost of the product. Product cost start date.

Table Indexes Table Name ProductCostH istory ProductCostH istory Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

PK_ProductCostHistory_ ProductID ProductID_StartDate PK_ProductCostHistory_ StartDate ProductID_StartDate

Dependent Objects Dependent Obj ufnGetProductStandardCost SQL_SCALAR_FUNCTION Dependent Obj Type

ProductDescription
Column Details Column Name Description Description ModifiedDate ProductDescriptionID ProductDescriptionID rowguid Data Type nvarchar nvarchar datetime int int uniqueidentifier (newid()) Length 400 400 (getdate()) Column Default Is Nullable NO NO NO NO NO NO Description Description of the product. Unique nonclustered index. Used to support replication samples. Date and time the record was last updated. Primary key for ProductDescription records. Clustered index created by a primary key constraint. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

Table Indexes Table Name ProductDescri ption ProductDescri ption Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_ProductDescription_ ProductDescriptio CLUSTERED ProductDescriptionID nID AK_ProductDescription_r rowguid NONCLUSTE owguid RED

Dependent Objects Dependent Obj vProductAndDescription VIEW Dependent Obj Type

ProductDocument
Column Details Column Name DocumentID ModifiedDate ProductID ProductID int datetime int int (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO Description Document identification number. Foreign key to Document.DocumentID. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Clustered index created by a primary key constraint.

Table Indexes

Table Name ProductDocu ment ProductDocu ment

Index Name

Column Name

Index Type CLUSTERED CLUSTERED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false

Is Padded false false

Is Hypothetical false false

PK_ProductDocument_P ProductID roductID_DocumentID PK_ProductDocument_P DocumentID roductID_DocumentID

Dependent Objects ---None---

ProductInventory
Column Details Column Name Bin LocationID ModifiedDate ProductID ProductID Quantity rowguid Shelf Data Type tinyint smallint datetime int int smallint uniqueidentifier nvarchar 10 ((0)) (newid()) (getdate()) Length Column Default Is Nullable NO NO NO NO NO NO NO NO Description Storage container on a shelf in an inventory location. Inventory location identification number. Foreign key to Location.LocationID. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Clustered index created by a primary key constraint. Quantity of products in the inventory location. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Storage compartment within an inventory location.

Table Indexes Table Name ProductInvent ory ProductInvent ory Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

PK_ProductInventory_Pr ProductID oductID_LocationID PK_ProductInventory_Pr LocationID oductID_LocationID

Dependent Objects Dependent Obj ufnGetStock SQL_SCALAR_FUNCTION Dependent Obj Type

ProductListPriceHistory
Column Details Column Name EndDate ListPrice ModifiedDate ProductID ProductID StartDate Data Type datetime money datetime int int datetime (getdate()) Length Column Default Is Nullable YES NO NO NO NO NO Description List price end date Product list price. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID Clustered index created by a primary key constraint. List price start date.

Table Indexes Table Name ProductListPri ceHistory ProductListPri ceHistory Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

PK_ProductListPriceHist ProductID ory_ProductID_StartDate PK_ProductListPriceHist StartDate ory_ProductID_StartDate

Dependent Objects Dependent Obj ufnGetProductDealerPrice ufnGetProductListPrice SQL_SCALAR_FUNCTION SQL_SCALAR_FUNCTION Dependent Obj Type

ProductModel
Column Details Column Name CatalogDescription CatalogDescription Instructions ModifiedDate Name xml xml xml datetime nvarchar 50 Data Type Length -1 -1 -1 (getdate()) Column Default Is Nullable YES YES YES NO NO Description Detailed product catalog information in xml format. Unique nonclustered index. Used to support replication samples. Manufacturing instructions in xml format. Date and time the record was last updated. Product model description.

Column Name Name ProductModelID ProductModelID rowguid

Data Type nvarchar int int uniqueidentifier

Length 50

Column Default

Is Nullable NO NO NO

Description Unique nonclustered index. Primary key for ProductModel records. Clustered index created by a primary key constraint. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

(newid())

NO

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false true false false false false false false false false false false false false false false Is Padded false false false false false Is Hypothetical false false false false false

ProductModel PK_ProductModel_Produ ProductModelID ctModelID ProductModel AK_ProductModel_Name Name

ProductModel AK_ProductModel_rowg rowguid uid ProductModel PXML_ProductModel_Ca CatalogDescriptio XML talogDescription n ProductModel PXML_ProductModel_In Instructions XML structions

Dependent Objects Dependent Obj vProductAndDescription vProductModelCatalogDescription VIEW VIEW Dependent Obj Type

Dependent Obj vProductModelInstructions VIEW

Dependent Obj Type

ProductModelIllustration
Column Details Column Name IllustrationID ModifiedDate ProductModelID ProductModelID int datetime int int (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO Description Primary key. Foreign key to Illustration.IllustrationID. Date and time the record was last updated. Primary key. Foreign key to ProductModel.ProductModelID. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

ProductModel PK_ProductModelIllustrat ProductModelID ion_ProductModelID_Illu Illustration strationID ProductModel PK_ProductModelIllustrat IllustrationID ion_ProductModelID_Illu Illustration strationID

Dependent Objects ---None---

ProductModelProductDescriptionCulture
Column Details Column Name CultureID ModifiedDate ProductDescriptionID ProductModelID ProductModelID Data Type nchar datetime int int int Length 6 (getdate()) Column Default Is Nullable NO NO NO NO NO Description Culture identification number. Foreign key to Culture.CultureID. Date and time the record was last updated. Primary key. Foreign key to ProductDescription.ProductDescriptionID. Primary key. Foreign key to ProductModel.ProductModelID. Clustered index created by a primary key constraint.

Table Indexes Table Name ProductModel ProductDescri ptionCulture Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

PK_ProductModelProduc tDescriptionCulture_Prod ProductModelID CLUSTERED uctModelID_ProductDes criptionID_CultureID ProductModel PK_ProductModelProduc ProductDescriptio ProductDescri tDescriptionCulture_Prod nID CLUSTERED ptionCulture uctModelID_ProductDes criptionID_CultureID

true

true

false

false

false

false

Table Name ProductModel ProductDescri ptionCulture

Index Name

Column Name

Index Type

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false

Is Padded false

Is Hypothetical false

PK_ProductModelProduc tDescriptionCulture_Prod CultureID uctModelID_ProductDes criptionID_CultureID

CLUSTERED

Dependent Objects Dependent Obj vProductAndDescription VIEW Dependent Obj Type

ProductPhoto
Column Details Column Name LargePhoto LargePhotoFileName ModifiedDate ProductPhotoID ProductPhotoID ThumbNailPhoto ThumbnailPhotoFileName Data Type varbinary nvarchar datetime int int varbinary nvarchar -1 50 Length -1 50 (getdate()) Column Default Is Nullable YES YES NO NO NO YES YES Description Large image of the product. Large image file name. Date and time the record was last updated. Primary key for ProductPhoto records. Clustered index created by a primary key constraint. Small image of the product. Small image file name.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

ProductPhoto PK_ProductPhoto_Produ ProductPhotoID ctPhotoID

Dependent Objects ---None---

ProductProductPhoto
Column Details Column Name ModifiedDate Primary ProductID ProductPhotoID ProductPhotoID Data Type datetime bit int int int Length Column Default (getdate()) ((0)) Is Nullable NO NO NO NO NO Description Date and time the record was last updated. 0 = Photo is not the principal image. 1 = Photo is the principal image. Product identification number. Foreign key to Product.ProductID. Product photo identification number. Foreign key to ProductPhoto.ProductPhotoID. Nonclustered index created by a primary key constraint.

Table Indexes

Table Name

Index Name

Column Name

Index Type NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false

Is Padded false false

Is Hypothetical false false

ProductProdu PK_ProductProductPhot ProductID o_ProductID_ProductPh ctPhoto otoID ProductProdu PK_ProductProductPhot ProductPhotoID o_ProductID_ProductPh ctPhoto otoID

Dependent Objects ---None---

ProductReview
Column Details Column Name Comments EmailAddress ModifiedDate ProductID ProductID ProductReviewID ProductReviewID Rating ReviewDate Data Type nvarchar nvarchar datetime int int int int int datetime (getdate()) Length 3850 50 (getdate()) Column Default Is Nullable YES NO NO NO NO NO NO NO NO Description Reviewer's comments Reviewer's e-mail address. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Nonclustered index. Primary key for ProductReview records. Clustered index created by a primary key constraint. Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating. Date review was submitted.

Column Name ReviewerName

Data Type nvarchar

Length 50

Column Default

Is Nullable NO

Description Name of the reviewer.

Table Indexes Table Name ProductRevie w ProductRevie w ProductRevie w ProductRevie w Index Name PK_ProductReview_Prod uctReviewID IX_ProductReview_Prod uctID_Name IX_ProductReview_Prod uctID_Name IX_ProductReview_Prod uctID_Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false true false false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

ProductReviewID CLUSTERED ProductID ReviewerName Comments NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED

Dependent Objects ---None---

ProductSubcategory
Column Details Column Name ModifiedDate Name Data Type datetime nvarchar 50 Length Column Default (getdate()) Is Nullable NO NO Description Date and time the record was last updated. Subcategory description.

Column Name Name ProductCategoryID ProductCategoryID ProductSubcategoryID ProductSubcategoryID rowguid

Data Type nvarchar int int int int uniqueidentifier

Length 50

Column Default

Is Nullable NO NO NO NO NO

Description Unique nonclustered index. Used to support replication samples. Product category identification number. Foreign key to ProductCategory.ProductCategoryID. Unique nonclustered index. Primary key for ProductSubcategory records. Clustered index created by a primary key constraint. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

(newid())

NO

Table Indexes Table Name ProductSubca tegory ProductSubca tegory ProductSubca tegory Index Name PK_ProductSubcategory _ProductSubcategoryID AK_ProductSubcategory _Name AK_ProductSubcategory _rowguid Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false false false false false Is Padded false false false Is Hypothetical false false false

ProductSubcateg CLUSTERED oryID NONCLUSTE Name RED NONCLUSTE rowguid RED

Dependent Objects ---None---

ScrapReason
Column Details Column Name ModifiedDate Name Name ScrapReasonID ScrapReasonID Data Type datetime nvarchar nvarchar smallint smallint 50 50 Length Column Default (getdate()) Is Nullable NO NO NO NO NO Description Date and time the record was last updated. Failure description. Unique nonclustered index. Primary key for ScrapReason records. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

ScrapReason PK_ScrapReason_Scrap ScrapReasonID ReasonID ScrapReason AK_ScrapReason_Name Name

Dependent Objects ---None---

TransactionHistory
Column Details Column Name ActualCost ModifiedDate ProductID ProductID Quantity ReferenceOrderID ReferenceOrderID ReferenceOrderLineID TransactionDate TransactionID TransactionID TransactionType Data Type money datetime int int int int int int datetime int int nchar 1 ((0)) (getdate()) (getdate()) Length Column Default Is Nullable NO NO NO NO NO NO NO NO NO NO NO NO Product cost. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Nonclustered index. Product quantity. Purchase order, sales order, or work order identification number. Nonclustered index. Line number associated with the purchase order, sales order, or work order. Date and time of the transaction. Primary key for TransactionHistory records. Clustered index created by a primary key constraint. W = WorkOrder, S = SalesOrder, P = PurchaseOrder Description

Table Indexes Table Name TransactionHi story TransactionHi story Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true false true false false false false false Is Padded false false Is Hypothetical false false

PK_TransactionHistory_ TransactionID TransactionID IX_TransactionHistory_P ProductID roductID

Table Name

Index Name

Column Name

Index Type

Is Is Is Unique Is Primary Constraint Disabled Unique Key false false false false false false false false

Is Padded false false

Is Hypothetical false false

TransactionHi IX_TransactionHistory_R ReferenceOrderI NONCLUSTE eferenceOrderID_Refere D story RED nceOrderLineID TransactionHi IX_TransactionHistory_R ReferenceOrderLi NONCLUSTE eferenceOrderID_Refere neID story RED nceOrderLineID

Dependent Objects Dependent Obj iduSalesOrderDetail iPurchaseOrderDetail iWorkOrder uPurchaseOrderDetail uWorkOrder SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER Dependent Obj Type

TransactionHistoryArchive
Column Details Column Name ActualCost ModifiedDate ProductID ProductID Data Type money datetime int int (getdate()) Length Column Default Is Nullable NO NO NO NO Product cost. Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Nonclustered index. Description

Column Name Quantity ReferenceOrderID ReferenceOrderID ReferenceOrderLineID TransactionDate TransactionID TransactionID TransactionType int int int int

Data Type

Length

Column Default

Is Nullable NO NO NO

Description Product quantity. Purchase order, sales order, or work order identification number. Nonclustered index. Line number associated with the purchase order, sales order, or work order. Date and time of the transaction. Primary key for TransactionHistoryArchive records. Clustered index created by a primary key constraint. W = Work Order, S = Sales Order, P = Purchase Order

((0)) (getdate())

NO NO NO NO

datetime int int nchar 1

NO

Table Indexes Table Name TransactionHi storyArchive TransactionHi storyArchive Index Name Column Name TransactionID ProductID Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false true false false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

PK_TransactionHistoryAr chive_TransactionID IX_TransactionHistoryAr chive_ProductID TransactionHi IX_TransactionHistoryAr storyArchive chive_ReferenceOrderID _ReferenceOrderLineID TransactionHi IX_TransactionHistoryAr storyArchive chive_ReferenceOrderID _ReferenceOrderLineID

ReferenceOrderI NONCLUSTE D RED ReferenceOrderLi NONCLUSTE neID RED

Dependent Objects ---None---

UnitMeasure
Column Details Column Name ModifiedDate Name Name UnitMeasureCode UnitMeasureCode Data Type datetime nvarchar nvarchar nchar nchar 50 50 3 3 Length Column Default (getdate()) Is Nullable NO NO NO NO NO Description Date and time the record was last updated. Unit of measure description. Unique nonclustered index. Primary key. Clustered index created by a primary key constraint.

Table Indexes Table Name UnitMeasure UnitMeasure Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_UnitMeasure_UnitMe UnitMeasureCod CLUSTERED asureCode e NONCLUSTE AK_UnitMeasure_Name Name RED

Dependent Objects ---None---

WorkOrder
Column Details Column Name DueDate EndDate ModifiedDate OrderQty OrderQty ProductID ProductID ScrappedQty ScrapReasonID StartDate StockedQty WorkOrderID WorkOrderID Data Type datetime datetime datetime int int int int smallint smallint datetime int int int (getdate()) Length Column Default Is Nullable NO YES NO NO NO NO NO NO YES NO NO NO NO Description Work order due date. Work order end date. Date and time the record was last updated. Product quantity to build. Nonclustered index. Product identification number. Foreign key to Product.ProductID. Nonclustered index. Quantity that failed inspection. Reason for inspection failure. Work order start date. Quantity built and put in inventory. Primary key for WorkOrder records. Clustered index created by a primary key constraint.

Table Indexes Table Name WorkOrder Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

PK_WorkOrder_WorkOr WorkOrderID derID

Table Name WorkOrder WorkOrder

Index Name

Column Name

Index Type NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key false false false false false false false false

Is Padded false false

Is Hypothetical false false

IX_WorkOrder_ScrapRe ScrapReasonID asonID IX_WorkOrder_ProductI ProductID D

Dependent Objects Dependent Obj uWorkOrder WorkOrder SQL_TRIGGER USER_TABLE Dependent Obj Type

WorkOrderRouting
Column Details Column Name ActualCost ActualEndDate ActualResourceHrs ActualStartDate LocationID ModifiedDate OperationSequence Data Type money datetime decimal datetime smallint datetime smallint (getdate()) Length Column Default Is Nullable YES YES YES YES NO NO NO Description Actual manufacturing cost. Actual end date. Number of manufacturing hours used. Actual start date. Manufacturing location where the part is processed. Foreign key to Location.LocationID. Date and time the record was last updated. Primary key. Indicates the manufacturing process sequence.

Column Name PlannedCost ProductID ProductID ScheduledEndDate ScheduledStartDate WorkOrderID WorkOrderID

Data Type money int int datetime datetime int int

Length

Column Default

Is Nullable NO NO NO NO NO NO NO

Description Estimated manufacturing cost. Primary key. Foreign key to Product.ProductID. Nonclustered index. Planned manufacturing end date. Planned manufacturing start date. Primary key. Foreign key to WorkOrder.WorkOrderID. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false true true true false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

WorkOrderRo PK_WorkOrderRouting_ WorkOrderID WorkOrderID_ProductID uting _OperationSequence WorkOrderRo PK_WorkOrderRouting_ ProductID WorkOrderID_ProductID uting _OperationSequence

WorkOrderRo PK_WorkOrderRouting_ OperationSequen CLUSTERED WorkOrderID_ProductID ce uting _OperationSequence WorkOrderRo IX_WorkOrderRouting_P ProductID NONCLUSTE uting roductID RED

Dependent Objects ---None---

ProductVendor
Column Details Column Name AverageLeadTime AverageLeadTime LastReceiptCost LastReceiptDate MaxOrderQty MinOrderQty ModifiedDate OnOrderQty ProductID ProductID StandardPrice UnitMeasureCode VendorID VendorID int int money datetime int int datetime int int int money nchar int int 3 (getdate()) Data Type Length Column Default Is Nullable NO NO YES YES NO NO NO YES NO NO NO NO NO NO Description The average span of time (in days) between placing an order with the vendor and receiving the purchased product. Nonclustered index. The selling price when last purchased. Date the product was last received by the vendor. The minimum quantity that should be ordered. The maximum quantity that should be ordered. Date and time the record was last updated. The quantity currently on order. Primary key. Foreign key to Product.ProductID. Clustered index created by a primary key constraint. The vendor's usual selling price. The product's unit of measure. Primary key. Foreign key to Vendor.VendorID. Nonclustered index.

Table Indexes Table Name ProductVendo r ProductVendo r ProductVendo r ProductVendo r Index Name PK_ProductVendor_Prod uctID_VendorID PK_ProductVendor_Prod uctID_VendorID IX_ProductVendor_Unit MeasureCode IX_ProductVendor_Vend orID Column Name ProductID VendorID Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false true true false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

UnitMeasureCod NONCLUSTE e RED NONCLUSTE VendorID RED

Dependent Objects ---None---

PurchaseOrderDetail
Column Details Column Name DueDate LineTotal ModifiedDate OrderQty ProductID PurchaseOrderDetailID PurchaseOrderDetailID Data Type datetime money datetime smallint int int int (getdate()) Length Column Default Is Nullable NO NO NO NO NO NO NO Description Date the product is expected to be received. Per product subtotal. Computed as OrderQty * UnitPrice. Date and time the record was last updated. Quantity ordered. Product identification number. Foreign key to Product.ProductID. Primary key. One line number per purchased product. Nonclustered index.

Column Name PurchaseOrderID PurchaseOrderID ReceivedQty RejectedQty StockedQty UnitPrice int int

Data Type

Length

Column Default

Is Nullable NO NO NO NO NO NO

Description Primary key. Foreign key to PurchaseOrderHeader.PurchaseOrderID. Clustered index created by a primary key constraint. Quantity actually received from the vendor. Quantity rejected during inspection. Quantity accepted into inventory. Computed as ReceivedQty - RejectedQty. Vendor's selling price of a single product.

decimal decimal decimal money

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false true true false false false false false false false Is Padded false false false Is Hypothetical false false false

PurchaseOrd PK_PurchaseOrderDetail PurchaseOrderID CLUSTERED _PurchaseOrderID_Purc erDetail haseOrderDetailID PurchaseOrd PK_PurchaseOrderDetail PurchaseOrderD CLUSTERED _PurchaseOrderID_Purc etailID erDetail haseOrderDetailID PurchaseOrd IX_PurchaseOrderDetail ProductID erDetail _ProductID NONCLUSTE RED

Dependent Objects Dependent Obj iPurchaseOrderDetail uPurchaseOrderDetail SQL_TRIGGER SQL_TRIGGER Dependent Obj Type

Dependent Obj PurchaseOrderDetail USER_TABLE

Dependent Obj Type

PurchaseOrderHeader
Column Details Column Name EmployeeID Freight ModifiedDate OrderDate PurchaseOrderID PurchaseOrderID RevisionNumber RevisionNumber ShipDate ShipMethodID Status Status SubTotal TaxAmt TotalDue int money datetime datetime int int tinyint tinyint datetime int tinyint tinyint money money money ((1)) ((1)) ((0.00)) ((0.00)) ((0)) ((0)) ((0.00)) (getdate()) (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO Description Employee who created the purchase order. Foreign key to Employee.EmployeeID. Shipping cost. Date and time the record was last updated. Purchase order creation date. Primary key. Clustered index created by a primary key constraint. Incremental number to track changes to the purchase order over time. Nonclustered index. Estimated shipment date from the vendor. Shipping method. Foreign key to ShipMethod.ShipMethodID. Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete Nonclustered index. Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID. Tax amount. Total due to vendor. Computed as Subtotal + TaxAmt + Freight.

Column Name VendorID int

Data Type

Length

Column Default

Is Nullable NO

Description Vendor with whom the purchase order is placed. Foreign key to Vendor.VendorID.

Table Indexes Table Name PurchaseOrd erHeader PurchaseOrd erHeader PurchaseOrd erHeader Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false true false false false false false false false false Is Padded false false false Is Hypothetical false false false

PK_PurchaseOrderHead PurchaseOrderID CLUSTERED er_PurchaseOrderID IX_PurchaseOrderHeade VendorID NONCLUSTE r_VendorID RED IX_PurchaseOrderHeade EmployeeID NONCLUSTE r_EmployeeID RED

Dependent Objects Dependent Obj iPurchaseOrderDetail uPurchaseOrderDetail uPurchaseOrderHeader PurchaseOrderHeader SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER USER_TABLE Dependent Obj Type

ShipMethod
Column Details

Column Name ModifiedDate Name Name rowguid ShipBase ShipBase ShipMethodID ShipMethodID ShipRate

Data Type datetime nvarchar nvarchar uniqueidentifier money money int int money

Length

Column Default (getdate()) 50 50 (newid()) ((0.00)) ((0.00))

Is Nullable NO NO NO NO NO NO NO NO

Description Date and time the record was last updated. Shipping company name. Unique nonclustered index. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Minimum shipping charge. Unique nonclustered index. Used to support replication samples. Primary key for ShipMethod records. Clustered index created by a primary key constraint. Shipping charge per pound.

((0.00))

NO

Table Indexes Table Name ShipMethod ShipMethod ShipMethod Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false false false false false Is Padded false false false Is Hypothetical false false false

PK_ShipMethod_ShipMe ShipMethodID thodID AK_ShipMethod_Name Name

AK_ShipMethod_rowguid rowguid

Dependent Objects

---None---

Vendor
Column Details Column Name AccountNumber AccountNumber ActiveFlag CreditRating ModifiedDate Name PreferredVendorStatus PurchasingWebServiceURL VendorID VendorID Data Type nvarchar nvarchar bit tinyint datetime nvarchar bit nvarchar int int 1024 50 ((1)) (getdate()) Length 15 15 ((1)) Column Default Is Nullable NO NO NO NO NO NO NO YES NO NO Description Vendor account (identification) number. Unique nonclustered index. 0 = Vendor no longer used. 1 = Vendor is actively used. 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average Date and time the record was last updated. Company name. 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product. Vendor URL. Primary key for Vendor records. Clustered index created by a primary key constraint.

Table Indexes Table Name Vendor Index Name PK_Vendor_VendorID Column Name VendorID Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false Index Type

Table Name Vendor

Index Name AK_Vendor_AccountNu mber

Column Name AccountNumber

Index Type NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false

Is Padded false

Is Hypothetical false

Dependent Objects Dependent Obj vVendor VIEW Dependent Obj Type

VendorAddress
Column Details Column Name AddressID AddressID AddressTypeID ModifiedDate VendorID VendorID int int int datetime int int (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO NO Description Primary key. Foreign key to Address.AddressID. Nonclustered index. Address type. Foreign key to AddressType.AddressTypeID. Date and time the record was last updated. Primary key. Foreign key to Vendor.VendorID. Clustered index created by a primary key constraint.

Table Indexes

Table Name VendorAddres s VendorAddres s VendorAddres s

Index Name

Column Name

Index Type CLUSTERED CLUSTERED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false true true false false false false false false false

Is Padded false false false

Is Hypothetical false false false

PK_VendorAddress_Ven VendorID dorID_AddressID PK_VendorAddress_Ven AddressID dorID_AddressID IX_VendorAddress_Addr AddressID essID

Dependent Objects Dependent Obj vVendor VIEW Dependent Obj Type

VendorContact
Column Details Column Name ContactID ContactID ContactTypeID ContactTypeID ModifiedDate VendorID VendorID int int int int datetime int int (getdate()) Data Type Length Column Default Is Nullable NO NO NO NO NO NO NO Description Contact (Vendor employee) identification number. Foreign key to Contact.ContactID. Nonclustered index. Contact type such as sales manager, or sales agent. Nonclustered index. Date and time the record was last updated. Primary key. Clustered index created by a primary key constraint.

Table Indexes Table Name VendorContac t VendorContac t VendorContac t VendorContac t Index Name PK_VendorContact_Ven dorID_ContactID PK_VendorContact_Ven dorID_ContactID IX_VendorContact_Cont actID IX_VendorContact_Cont actTypeID Column Name VendorID ContactID ContactID ContactTypeID Index Type CLUSTERED CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false true true false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

Dependent Objects Dependent Obj ufnGetContactInformation vVendor VIEW Dependent Obj Type SQL_TABLE_VALUED_FUNCTION

ContactCreditCard
Column Details Column Name ContactID ContactID int int Data Type Length Column Default Is Nullable NO NO Description Customer identification number. Foreign key to Contact.ContactID. Clustered index created by a primary key constraint.

Column Name CreditCardID ModifiedDate int

Data Type

Length

Column Default

Is Nullable NO

Description Credit card identification number. Foreign key to CreditCard.CreditCardID. Date and time the record was last updated.

datetime

(getdate())

NO

Table Indexes Table Name ContactCredit Card ContactCredit Card Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

PK_ContactCreditCard_ ContactID ContactID_CreditCardID PK_ContactCreditCard_ CreditCardID ContactID_CreditCardID

Dependent Objects ---None---

CountryRegionCurrency
Column Details Column Name CountryRegionCode CountryRegionCode CurrencyCode Data Type nvarchar nvarchar nchar Length 3 3 3 Column Default Is Nullable NO NO NO Description ISO code for countries and regions. Foreign key to CountryRegion.CountryRegionCode. Clustered index created by a primary key constraint. ISO standard currency code. Foreign key to Currency.CurrencyCode.

Column Name CurrencyCode ModifiedDate

Data Type nchar datetime

Length 3

Column Default (getdate())

Is Nullable NO NO

Description Nonclustered index. Date and time the record was last updated.

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false true true false false false false false false false Is Padded false false false Is Hypothetical false false false

CountryRegio PK_CountryRegionCurre CountryRegionCo CLUSTERED ncy_CountryRegionCode de nCurrency _CurrencyCode CountryRegio PK_CountryRegionCurre CurrencyCode ncy_CountryRegionCode CLUSTERED nCurrency _CurrencyCode CountryRegio IX_CountryRegionCurren CurrencyCode nCurrency cy_CurrencyCode NONCLUSTE RED

Dependent Objects ---None---

CreditCard
Column Details Column Name CardNumber CardType Data Type nvarchar nvarchar Length 25 50 Column Default Is Nullable NO NO Description Credit card number. Credit card name.

Column Name CardType CreditCardID CreditCardID ExpMonth ExpYear ModifiedDate

Data Type nvarchar int int tinyint smallint datetime

Length 50

Column Default

Is Nullable NO NO NO NO NO

Description Unique nonclustered index. Primary key for CreditCard records. Clustered index created by a primary key constraint. Credit card expiration month. Credit card expiration year. Date and time the record was last updated.

(getdate())

NO

Table Indexes Table Name CreditCard CreditCard Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_CreditCard_CreditCa CreditCardID rdID AK_CreditCard_CardNu CardNumber mber

Dependent Objects ---None---

Currency
Column Details

Column Name CurrencyCode CurrencyCode ModifiedDate Name Name

Data Type nchar nchar datetime nvarchar nvarchar

Length 3 3

Column Default

Is Nullable NO NO

Description The ISO code for the Currency. Clustered index created by a primary key constraint. Date and time the record was last updated. Currency name. Unique nonclustered index.

(getdate()) 50 50

NO NO NO

Table Indexes Table Name Currency Currency Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_Currency_CurrencyC CurrencyCode ode AK_Currency_Name Name

Dependent Objects ---None---

CurrencyRate
Column Details Column Name AverageRate Data Type money Length Column Default Is Nullable NO Description Average exchange rate for the day.

Column Name CurrencyRateDate CurrencyRateDate CurrencyRateID CurrencyRateID EndOfDayRate FromCurrencyCode ModifiedDate ToCurrencyCode

Data Type datetime datetime int int money nchar datetime nchar

Length

Column Default

Is Nullable NO NO NO NO NO

Description Date and time the exchange rate was obtained. Unique nonclustered index. Primary key for CurrencyRate records. Clustered index created by a primary key constraint. Final exchange rate for the day. Exchange rate was converted from this currency code. Date and time the record was last updated. Exchange rate was converted to this currency code.

3 (getdate()) 3

NO NO NO

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

CurrencyRate PK_CurrencyRate_Curre CurrencyRateID ncyRateID AK_CurrencyRate_Curre CurrencyRate ncyRateDate_FromCurre CurrencyRateDat ncyCode_ToCurrencyCo e de AK_CurrencyRate_Curre CurrencyRate ncyRateDate_FromCurre FromCurrencyCo ncyCode_ToCurrencyCo de de AK_CurrencyRate_Curre CurrencyRate ncyRateDate_FromCurre ToCurrencyCode ncyCode_ToCurrencyCo de

true

false

false

false

false

false

true

false

false

false

false

false

Dependent Objects ---None---

Customer
Column Details Column Name AccountNumber AccountNumber CustomerID CustomerID CustomerType ModifiedDate rowguid rowguid TerritoryID TerritoryID Data Type varchar varchar int int nchar datetime uniqueidentifier uniqueidentifier int int 1 (getdate()) (newid()) (newid()) Length 10 10 Column Default Is Nullable NO NO NO NO NO NO NO NO YES YES Description Unique number identifying the customer assigned by the accounting system. Unique nonclustered index. Primary key for Customer records. Clustered index created by a primary key constraint. Customer type: I = Individual, S = Store Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Nonclustered index. ID of the territory in which the customer is located. Foreign key to SalesTerritory.SalesTerritoryID. Unique nonclustered index. Used to support replication samples.

Table Indexes Table Name Customer Customer Customer Customer Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false true false false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

PK_Customer_Customer CustomerID ID AK_Customer_rowguid rowguid

AK_Customer_AccountN AccountNumber umber IX_Customer_TerritoryID TerritoryID

Dependent Objects Dependent Obj ufnLeadingZeros Customer vIndividualCustomer vStoreWithDemographics SQL_SCALAR_FUNCTION USER_TABLE VIEW VIEW Dependent Obj Type

CustomerAddress
Column Details Column Name AddressID AddressID int int Data Type Length Column Default Is Nullable NO NO Description Primary key. Foreign key to Address.AddressID. Unique nonclustered index. Used to support replication samples.

Column Name AddressTypeID CustomerID CustomerID ModifiedDate rowguid int int int

Data Type

Length

Column Default

Is Nullable NO NO NO

Description Address type. Foreign key to AddressType.AddressTypeID. Primary key. Foreign key to Customer.CustomerID. Clustered index created by a primary key constraint. Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

datetime uniqueidentifier

(getdate()) (newid())

NO NO

Table Indexes Table Name CustomerAdd ress CustomerAdd ress CustomerAdd ress Index Name Column Name Index Type CLUSTERED CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true false false false false false false false Is Padded false false false Is Hypothetical false false false

PK_CustomerAddress_C CustomerID ustomerID_AddressID PK_CustomerAddress_C AddressID ustomerID_AddressID AK_CustomerAddress_r rowguid owguid

Dependent Objects Dependent Obj vIndividualCustomer vStoreWithDemographics VIEW VIEW Dependent Obj Type

Individual
Column Details Column Name ContactID CustomerID CustomerID Demographics ModifiedDate int int int xml datetime -1 (getdate()) Data Type Length Column Default Is Nullable NO NO NO YES NO Description Identifies the customer in the Contact table. Foreign key to Contact.ContactID. Unique customer identification number. Foreign key to Customer.CustomerID. Clustered index created by a primary key constraint. Personal information such as hobbies, and income collected from online shoppers. Used for sales analysis. Date and time the record was last updated.

Table Indexes Table Name Individual Individual Individual Individual Individual Index Name PK_Individual_CustomerI D PXML_Individual_Demog raphics XMLPATH_Individual_D emographics XMLPROPERTY_Individ ual_Demographics XMLVALUE_Individual_ Demographics Column Name CustomerID Demographics Demographics Demographics Demographics Index Type CLUSTERED XML XML XML XML Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false false true false false false false false false false false false false false false false false Is Padded false false false false false Is Hypothetical false false false false false

Dependent Objects Dependent Obj ufnGetContactInformation iduSalesOrderDetail iStore iuIndividual vIndividualCustomer vIndividualDemographics SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER VIEW VIEW Dependent Obj Type SQL_TABLE_VALUED_FUNCTION

SalesOrderDetail
Column Details Column Name CarrierTrackingNumber CarrierTrackingNumber LineTotal ModifiedDate OrderQty ProductID rowguid Data Type nvarchar nvarchar numeric datetime smallint int uniqueidentifier (newid()) (getdate()) Length 25 25 Column Default Is Nullable YES YES NO NO NO NO NO Description Shipment tracking number supplied by the shipper. Nonclustered index. Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty. Date and time the record was last updated. Quantity ordered per product. Product sold to customer. Foreign key to Product.ProductID. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

Column Name SalesOrderDetailID SalesOrderDetailID SalesOrderID SalesOrderID SpecialOfferID UnitPrice UnitPriceDiscount int int int int int

Data Type

Length

Column Default

Is Nullable NO NO NO NO NO NO

Description Primary key. One incremental unique number per product sold. Unique nonclustered index. Used to support replication samples. Primary key. Foreign key to SalesOrderHeader.SalesOrderID. Clustered index created by a primary key constraint. Promotional code. Foreign key to SpecialOffer.SpecialOfferID. Selling price of a single product. Discount amount.

money money ((0.0))

NO

Table Indexes Table Name Index Name Column Name Index Type Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false true true false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

SalesOrderDe PK_SalesOrderDetail_Sa SalesOrderID lesOrderID_SalesOrderD CLUSTERED tail etailID SalesOrderDe PK_SalesOrderDetail_Sa SalesOrderDetailI CLUSTERED lesOrderID_SalesOrderD D tail etailID SalesOrderDe tail SalesOrderDe tail AK_SalesOrderDetail_ro rowguid wguid IX_SalesOrderDetail_Pro ProductID ductID NONCLUSTE RED NONCLUSTE RED

Dependent Objects Dependent Obj iduSalesOrderDetail SalesOrderDetail SQL_TRIGGER USER_TABLE Dependent Obj Type

SalesOrderHeader
Column Details Column Name AccountNumber BillToAddressID Comment ContactID CreditCardApprovalCode CreditCardID CurrencyRateID CustomerID DueDate Freight ModifiedDate OnlineOrderFlag OrderDate OrderDate Data Type nvarchar int nvarchar int varchar int int int datetime money datetime bit datetime datetime ((0.00)) (getdate()) ((1)) (getdate()) (getdate()) 15 128 Length 15 Column Default Is Nullable YES NO YES NO YES YES YES NO NO NO NO NO NO NO Description Financial accounting number reference. Customer billing address. Foreign key to Address.AddressID. Sales representative comments. Customer contact identification number. Foreign key to Contact.ContactID. Approval code provided by the credit card company. Credit card identification number. Foreign key to CreditCard.CreditCardID. Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. Customer identification number. Foreign key to Customer.CustomerID. Date the order is due to the customer. Shipping cost. Date and time the record was last updated. 0 = Order placed by sales person. 1 = Order placed online by customer. Dates the sales order was created. Unique nonclustered index.

Column Name PurchaseOrderNumber RevisionNumber RevisionNumber rowguid SalesOrderID SalesOrderID SalesOrderNumber SalesPersonID ShipDate ShipDate ShipMethodID ShipToAddressID Status Status SubTotal TaxAmt TerritoryID TotalDue

Data Type nvarchar tinyint tinyint uniqueidentifier int int nvarchar int datetime datetime int int tinyint tinyint money money int money

Length 25

Column Default

Is Nullable YES

Description Customer purchase order number reference. Incremental number to track changes to the sales order over time. Unique nonclustered index. Used to support replication samples. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Primary key. Clustered index created by a primary key constraint. Unique sales order identification number. Sales person who created the sales order. Foreign key to SalesPerson.SalePersonID. Date the order was shipped to the customer. Nonclustered index. Shipping method. Foreign key to ShipMethod.ShipMethodID. Customer shipping address. Foreign key to Address.AddressID. Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled Nonclustered index. Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. Tax amount. Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. Total due from customer. Computed as Subtotal + TaxAmt + Freight.

((0)) ((0)) (newid())

NO NO NO NO NO

25

NO YES YES YES NO NO ((1)) ((1)) ((0.00)) ((0.00)) NO NO NO NO YES NO

Table Indexes Table Name SalesOrderHe ader SalesOrderHe ader SalesOrderHe ader SalesOrderHe ader SalesOrderHe ader Index Name PK_SalesOrderHeader_ SalesOrderID AK_SalesOrderHeader_r owguid AK_SalesOrderHeader_ SalesOrderNumber IX_SalesOrderHeader_C ustomerID IX_SalesOrderHeader_S alesPersonID Column Name SalesOrderID rowguid Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false true false false false false false false false false false false false false false false Is Padded false false false false false Is Hypothetical false false false false false

NONCLUSTE RED SalesOrderNumb NONCLUSTE er RED NONCLUSTE CustomerID RED NONCLUSTE SalesPersonID RED

Dependent Objects Dependent Obj iduSalesOrderDetail uSalesOrderHeader SalesOrderHeader vSalesPersonSalesByFiscalYears SQL_TRIGGER SQL_TRIGGER USER_TABLE VIEW Dependent Obj Type

SalesOrderHeaderSalesReason
Column Details

Column Name ModifiedDate SalesOrderID SalesOrderID SalesReasonID

Data Type datetime int int int

Length

Column Default (getdate())

Is Nullable NO NO NO NO

Description Date and time the record was last updated. Primary key. Foreign key to SalesOrderHeader.SalesOrderID. Clustered index created by a primary key constraint. Primary key. Foreign key to SalesReason.SalesReasonID.

Table Indexes Table Name SalesOrderHe aderSalesRea son SalesOrderHe aderSalesRea son Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

PK_SalesOrderHeaderS alesReason_SalesOrderI SalesOrderID D_SalesReasonID PK_SalesOrderHeaderS alesReason_SalesOrderI SalesReasonID D_SalesReasonID

Dependent Objects ---None---

SalesPerson
Column Details

Column Name Bonus CommissionPct ModifiedDate rowguid SalesLastYear SalesPersonID SalesPersonID SalesQuota SalesYTD TerritoryID TerritoryID

Data Type money smallmoney datetime uniqueidentifier money int int money money int int

Length

Column Default ((0.00)) ((0.00)) (getdate()) (newid()) ((0.00))

Is Nullable NO NO NO NO NO NO NO YES

Description Bonus due if quota is met. Commision percent received per sale. Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Sales total of previous year. Primary key for SalesPerson records. Clustered index created by a primary key constraint. Projected yearly sales. Sales total year to date. Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID. Unique nonclustered index. Used to support replication samples.

((0.00))

NO YES YES

Table Indexes Table Name SalesPerson SalesPerson Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_SalesPerson_SalesP SalesPersonID ersonID AK_SalesPerson_rowgui rowguid d

Dependent Objects Dependent Obj uSalesOrderHeader vSalesPerson vSalesPersonSalesByFiscalYears SQL_TRIGGER VIEW VIEW Dependent Obj Type

SalesPersonQuotaHistory
Column Details Column Name ModifiedDate QuotaDate QuotaDate rowguid SalesPersonID SalesPersonID SalesQuota Data Type datetime datetime datetime uniqueidentifier int int money (newid()) Length Column Default (getdate()) Is Nullable NO NO NO NO NO NO NO Description Date and time the record was last updated. Sales quota date. Unique nonclustered index. Used to support replication samples. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Sales person identification number. Foreign key to SalesPerson.SalesPersonID. Clustered index created by a primary key constraint. Sales quota amount.

Table Indexes

Table Name

Index Name

Column Name

Index Type CLUSTERED CLUSTERED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true false false false false false false false

Is Padded false false false

Is Hypothetical false false false

SalesPerson PK_SalesPersonQuotaHi SalesPersonID QuotaHistory story_SalesPersonID_Qu otaDate SalesPerson PK_SalesPersonQuotaHi QuotaDate QuotaHistory story_SalesPersonID_Qu otaDate SalesPerson AK_SalesPersonQuotaHi rowguid QuotaHistory story_rowguid

Dependent Objects ---None---

SalesReason
Column Details Column Name ModifiedDate Name ReasonType SalesReasonID SalesReasonID Data Type datetime nvarchar nvarchar int int 50 50 Length Column Default (getdate()) Is Nullable NO NO NO NO NO Description Date and time the record was last updated. Sales reason description. Category the sales reason belongs to. Primary key for SalesReason records. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true false false Is Padded false Is Hypothetical false

SalesReason PK_SalesReason_Sales SalesReasonID ReasonID

Dependent Objects ---None---

SalesTaxRate
Column Details Column Name ModifiedDate Name rowguid SalesTaxRateID SalesTaxRateID StateProvinceID StateProvinceID TaxRate TaxType Data Type datetime nvarchar uniqueidentifier int int int int smallmoney tinyint ((0.00)) 50 (newid()) Length Column Default (getdate()) Is Nullable NO NO NO NO NO NO NO NO NO Description Date and time the record was last updated. Tax rate description. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Primary key for SalesTaxRate records. Clustered index created by a primary key constraint. State, province, or country/region the sales tax applies to. Unique nonclustered index. Tax rate amount. 1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions.

Column Name TaxType

Data Type tinyint

Length

Column Default

Is Nullable NO

Description Unique nonclustered index. Used to support replication samples.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true false false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

SalesTaxRate PK_SalesTaxRate_Sales SalesTaxRateID TaxRateID SalesTaxRate AK_SalesTaxRate_State StateProvinceID ProvinceID_TaxType SalesTaxRate AK_SalesTaxRate_State TaxType ProvinceID_TaxType SalesTaxRate AK_SalesTaxRate_rowg rowguid uid

Dependent Objects ---None---

SalesTerritory
Column Details Column Name CostLastYear CostYTD Data Type money money Length Column Default ((0.00)) ((0.00)) Is Nullable NO NO Description Business costs in the territory the previous year. Business costs in the territory year to date.

Column Name CountryRegionCode CountryRegionCode Group ModifiedDate Name Name rowguid SalesLastYear SalesYTD TerritoryID TerritoryID

Data Type nvarchar nvarchar nvarchar datetime nvarchar nvarchar uniqueidentifier money money int int

Length 3 3 50

Column Default

Is Nullable NO NO NO

Description ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. Unique nonclustered index. Used to support replication samples. Geographic area to which the sales territory belong. Date and time the record was last updated. Sales territory description Unique nonclustered index. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Sales in the territory the previous year. Sales in the territory year to date. Primary key for SalesTerritory records. Clustered index created by a primary key constraint.

(getdate()) 50 50 (newid()) ((0.00)) ((0.00))

NO NO NO NO NO NO NO NO

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false false false false false Is Padded false false false Is Hypothetical false false false

SalesTerritory PK_SalesTerritory_Territ TerritoryID oryID SalesTerritory AK_SalesTerritory_Nam Name e SalesTerritory AK_SalesTerritory_rowg rowguid uid

Dependent Objects Dependent Obj uSalesOrderHeader vSalesPerson vSalesPersonSalesByFiscalYears SQL_TRIGGER VIEW VIEW Dependent Obj Type

SalesTerritoryHistory
Column Details Column Name EndDate ModifiedDate rowguid SalesPersonID SalesPersonID StartDate TerritoryID TerritoryID Data Type datetime datetime uniqueidentifier int int datetime int int (getdate()) (newid()) Length Column Default Is Nullable YES NO NO NO NO NO NO NO Description Date the sales representative left work in the territory. Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Primary key for SalesTerritoryHistory records. Clustered index created by a primary key constraint. Date the sales representive started work in the territory. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID. Unique nonclustered index. Used to support replication samples.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED CLUSTERED CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true true true true false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

SalesTerritory PK_SalesTerritoryHistory SalesPersonID _SalesPersonID_StartDa History te_TerritoryID SalesTerritory PK_SalesTerritoryHistory TerritoryID _SalesPersonID_StartDa History te_TerritoryID SalesTerritory PK_SalesTerritoryHistory StartDate _SalesPersonID_StartDa History te_TerritoryID SalesTerritory AK_SalesTerritoryHistory rowguid History _rowguid

Dependent Objects ---None---

ShoppingCartItem
Column Details Column Name DateCreated ModifiedDate ProductID Quantity ShoppingCartID ShoppingCartID Data Type datetime datetime int int nvarchar nvarchar 50 50 ((1)) Length Column Default (getdate()) (getdate()) Is Nullable NO NO NO NO NO NO Description Date the time the record was created. Date and time the record was last updated. Product ordered. Foreign key to Product.ProductID. Product quantity ordered. Shopping cart identification number. Nonclustered index.

Column Name ShoppingCartItemID ShoppingCartItemID int int

Data Type

Length

Column Default

Is Nullable NO NO

Description Primary key for ShoppingCartItem records. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false true false false false false false false false false Is Padded false false false Is Hypothetical false false false

ShoppingCartI PK_ShoppingCartItem_S ShoppingCartIte tem hoppingCartItemID mID ShoppingCartI IX_ShoppingCartItem_S ShoppingCartID hoppingCartID_ProductI tem D ShoppingCartI IX_ShoppingCartItem_S ProductID hoppingCartID_ProductI tem D

Dependent Objects ---None---

SpecialOffer
Column Details Column Name Category Data Type nvarchar Length 50 Column Default Is Nullable NO Description Group the discount applies to such as Reseller or Customer.

Column Name Description Description DiscountPct EndDate MaxQty MinQty ModifiedDate rowguid SpecialOfferID SpecialOfferID StartDate Type

Data Type nvarchar nvarchar smallmoney datetime int int datetime uniqueidentifier int int datetime nvarchar

Length 255 255

Column Default

Is Nullable NO NO

Description Discount description. Unique nonclustered index. Used to support replication samples. Discount precentage. Discount end date. Maximum discount percent allowed. Minimum discount percent allowed. Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Primary key for SpecialOffer records. Clustered index created by a primary key constraint. Discount start date. Discount type category.

((0.00))

NO NO YES

((0)) (getdate()) (newid())

NO NO NO NO NO NO

50

NO

Table Indexes Table Name SpecialOffer SpecialOffer Index Name Column Name Index Type CLUSTERED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false false false false false Is Padded false false Is Hypothetical false false

PK_SpecialOffer_Special SpecialOfferID OfferID AK_SpecialOffer_rowgui rowguid d

Dependent Objects ---None---

SpecialOfferProduct
Column Details Column Name ModifiedDate ProductID ProductID rowguid rowguid SpecialOfferID SpecialOfferID Data Type datetime int int uniqueidentifier uniqueidentifier int int (newid()) (newid()) Length Column Default (getdate()) Is Nullable NO NO NO NO NO NO NO Description Date and time the record was last updated. Product identification number. Foreign key to Product.ProductID. Unique nonclustered index. Used to support replication samples. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Nonclustered index. Primary key for SpecialOfferProduct records. Clustered index created by a primary key constraint.

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED CLUSTERED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true true false false false false Is Padded false false Is Hypothetical false false

SpecialOfferP PK_SpecialOfferProduct SpecialOfferID _SpecialOfferID_Product roduct ID SpecialOfferP PK_SpecialOfferProduct ProductID _SpecialOfferID_Product roduct ID

Table Name SpecialOfferP roduct SpecialOfferP roduct

Index Name

Column Name

Index Type NONCLUSTE RED NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key true false false false false false false false

Is Padded false false

Is Hypothetical false false

AK_SpecialOfferProduct rowguid _rowguid IX_SpecialOfferProduct_ ProductID ProductID

Dependent Objects ---None---

Store
Column Details Column Name CustomerID CustomerID Demographics ModifiedDate Name Name rowguid int int xml datetime nvarchar nvarchar uniqueidentifier 50 50 (newid()) -1 (getdate()) Data Type Length Column Default Is Nullable NO NO YES NO NO NO NO Description Primary key. Foreign key to Customer.CustomerID. Clustered index created by a primary key constraint. Demographic informationg about the store such as the number of employees, annual sales and store type. Date and time the record was last updated. Name of the store. Unique nonclustered index. Used to support replication samples. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.

Column Name SalesPersonID SalesPersonID int int

Data Type

Length

Column Default

Is Nullable YES YES

Description ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID. Nonclustered index.

Table Indexes Table Name Store Store Store Store Index Name PK_Store_CustomerID AK_Store_rowguid Column Name CustomerID rowguid Is Is Is Unique Is Is Is Primary Constraint Disabled Padded Hypothetical Unique Key CLUSTERED true true false false false false NONCLUSTE true false false false false false RED NONCLUSTE false false false false false false RED Index Type XML false false false false false false

IX_Store_SalesPersonID SalesPersonID PXML_Store_Demograp Demographics hics

Dependent Objects Dependent Obj iuIndividual vStoreWithDemographics SQL_TRIGGER VIEW Dependent Obj Type

StoreContact
Column Details

Column Name ContactID ContactID ContactTypeID ContactTypeID CustomerID CustomerID ModifiedDate rowguid rowguid int int int int int int

Data Type

Length

Column Default

Is Nullable NO NO NO NO NO NO

Description Contact (store employee) identification number. Foreign key to Contact.ContactID. Unique nonclustered index. Used to support replication samples. Contact type such as owner or purchasing agent. Foreign key to ContactType.ContactTypeID. Nonclustered index. Store identification number. Foreign key to Customer.CustomerID. Clustered index created by a primary key constraint. Date and time the record was last updated. ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. Nonclustered index.

datetime uniqueidentifier uniqueidentifier

(getdate()) (newid()) (newid())

NO NO NO

Table Indexes Table Name Index Name Column Name Index Type CLUSTERED CLUSTERED NONCLUSTE RED NONCLUSTE RED Is Is Is Unique Is Primary Constraint Disabled Unique Key true true true false true true false false false false false false false false false false Is Padded false false false false Is Hypothetical false false false false

StoreContact PK_StoreContact_Custo CustomerID merID_ContactID StoreContact PK_StoreContact_Custo ContactID merID_ContactID StoreContact AK_StoreContact_rowgui rowguid d StoreContact IX_StoreContact_Contac ContactID tID

Table Name

Index Name

Column Name

Index Type NONCLUSTE RED

Is Is Is Unique Is Primary Constraint Disabled Unique Key false false false false

Is Padded false

Is Hypothetical false

StoreContact IX_StoreContact_Contac ContactTypeID tTypeID

Dependent Objects Dependent Obj ufnGetContactInformation vStoreWithDemographics VIEW Dependent Obj Type SQL_TABLE_VALUED_FUNCTION

Views
View Name vEmployee vEmployeeDepartment vEmployeeDepartmentHistory vJobCandidate vJobCandidateEducation vJobCandidateEmployment vAdditionalContactInfo vStateProvinceCountryRegion vProductAndDescription vProductModelCatalogDescription vProductModelInstructions View Schema HumanResources HumanResources HumanResources HumanResources HumanResources HumanResources Person Person Production Production Production

View Name vVendor vIndividualCustomer vIndividualDemographics vSalesPerson vSalesPersonSalesByFiscalYears vStoreWithDemographics Purchasing Sales Sales Sales Sales Sales

View Schema

vEmployee
Column Details Column Name AdditionalContactInfo AddressLine1 AddressLine2 City CountryRegionName EmailAddress EmailPromotion EmployeeID FirstName JobTitle LastName MiddleName Phone xml nvarchar nvarchar nvarchar nvarchar nvarchar int int nvarchar nvarchar nvarchar nvarchar nvarchar 50 50 50 50 25 Data Type Length -1 60 60 30 50 50 Column Default Is Nullable YES NO YES NO NO YES NO NO NO NO NO YES YES Description

Column Name PostalCode StateProvinceName Suffix Title

Data Type nvarchar nvarchar nvarchar nvarchar

Length 15 50 10 8

Column Default

Is Nullable NO NO YES YES

Description

View Definition

View Definition CREATE VIEW [HumanResources].[vEmployee] AS SELECT e.[EmployeeID] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,e.[Title] AS [JobTitle] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,sp.[Name] AS [StateProvinceName] ,a.[PostalCode] ,cr.[Name] AS [CountryRegionName] ,c.[AdditionalContactInfo] FROM [HumanResources].[Employee] e INNER JOIN [Person].[Contact] c ON c.[ContactID] = e.[ContactID] INNER JOIN [HumanResources].[EmployeeAddress] ea ON e.[EmployeeID] = ea.[EmployeeID] INNER JOIN [Person].[Address] a ON ea.[AddressID] = a.[AddressID] INNER JOIN [Person].[StateProvince] sp ON sp.[StateProvinceID] = a.[StateProvinceID] INNER JOIN [Person].[CountryRegion] cr ON cr.[CountryRegionCode] = sp.[CountryRegionCode];

Tables Used in View Table Catalog AdventureWorks Table Schema HumanResources Employee Table Name

Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Person Person Person Person

Table Schema HumanResources EmployeeAddress Address Contact CountryRegion StateProvince

Table Name

Dependent Objects Dependent Obj Address Contact CountryRegion Employee EmployeeAddress StateProvince USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vEmployeeDepartment
Column Details Column Name Department EmployeeID FirstName GroupName Data Type nvarchar int nvarchar nvarchar 50 50 Length 50 Column Default Is Nullable NO NO NO NO Description

Column Name JobTitle LastName MiddleName StartDate Suffix Title

Data Type nvarchar nvarchar nvarchar datetime nvarchar nvarchar

Length 50 50 50 10 8

Column Default

Is Nullable NO NO YES NO YES YES

Description

View Definition View Definition CREATE VIEW [HumanResources].[vEmployeeDepartment] AS SELECT e.[EmployeeID] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,e.[Title] AS [JobTitle] ,d.[Name] AS [Department] ,d.[GroupName] ,edh.[StartDate] FROM [HumanResources].[Employee] e INNER JOIN [Person].[Contact] c ON c.[ContactID] = e.[ContactID] INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh ON e.[EmployeeID] = edh.[EmployeeID] INNER JOIN [HumanResources].[Department] d ON edh.[DepartmentID] = d.[DepartmentID] WHERE GETDATE() BETWEEN edh.[StartDate] AND ISNULL(edh.[EndDate], GETDATE());

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks Table Schema HumanResources HumanResources HumanResources Person Department Employee EmployeeDepartmentHistory Contact Table Name

Dependent Objects Dependent Obj Contact Department Employee EmployeeDepartmentHistory USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vEmployeeDepartmentHistory
Column Details Column Name Department EmployeeID EndDate Data Type nvarchar int datetime Length 50 Column Default Is Nullable NO NO YES Description

Column Name FirstName GroupName LastName MiddleName Shift StartDate Suffix Title

Data Type nvarchar nvarchar nvarchar nvarchar nvarchar datetime nvarchar nvarchar

Length 50 50 50 50 50 10 8

Column Default

Is Nullable NO NO NO YES NO NO YES YES

Description

View Definition

View Definition CREATE VIEW [HumanResources].[vEmployeeDepartmentHistory] AS SELECT e.[EmployeeID] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,s.[Name] AS [Shift] ,d.[Name] AS [Department] ,d.[GroupName] ,edh.[StartDate] ,edh.[EndDate] FROM [HumanResources].[Employee] e INNER JOIN [Person].[Contact] c ON c.[ContactID] = e.[ContactID] INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh ON e.[EmployeeID] = edh.[EmployeeID] INNER JOIN [HumanResources].[Department] d ON edh.[DepartmentID] = d.[DepartmentID] INNER JOIN [HumanResources].[Shift] s ON s.[ShiftID] = edh.[ShiftID];

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Table Schema HumanResources HumanResources HumanResources HumanResources Person Department Employee EmployeeDepartmentHistory Shift Contact Table Name

Dependent Objects Dependent Obj Contact Department Employee EmployeeDepartmentHistory Shift USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vJobCandidate
Column Details Column Name Addr.Loc.City Addr.Loc.CountryRegion Addr.Loc.State Addr.PostalCode Addr.Type EMail EmployeeID JobCandidateID ModifiedDate Name.First Name.Last Data Type nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar int int datetime nvarchar nvarchar 30 30 Length 100 100 100 20 30 -1 Column Default Is Nullable YES YES YES YES YES YES YES NO NO YES YES Description

Column Name Name.Middle Name.Prefix Name.Suffix Skills WebSite

Data Type nvarchar nvarchar nvarchar nvarchar nvarchar

Length 30 30 30 -1 -1

Column Default

Is Nullable YES YES YES YES YES

Description

View Definition

View Definition CREATE VIEW [HumanResources].[vJobCandidate] AS SELECT jc.[JobCandidateID] ,jc.[EmployeeID] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Name/Name.Prefix)[1]', 'nvarchar(30)') AS [Name.Prefix] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Name/Name.First)[1]', 'nvarchar(30)') AS [Name.First] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Name/Name.Middle)[1]', 'nvarchar(30)') AS [Name.Middle] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Name/Name.Last)[1]', 'nvarchar(30)') AS [Name.Last] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Name/Name.Suffix)[1]', 'nvarchar(30)') AS [Name.Suffix] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/Skills)[1]', 'nvarchar(max)') AS [Skills] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Address/Addr.Type)[1]', 'nvarchar(30)') AS [Addr.Type] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Address/Addr.Location/Location/Loc.CountryRegion)[1]', 'nvarchar(100)') AS [Addr.Loc.CountryRegion] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Address/Addr.Location/Location/Loc.State)[1]', 'nvarchar(100)') AS [Addr.Loc.State] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Address/Addr.Location/Location/Loc.City)[1]', 'nvarchar(100)') AS [Addr.Loc.City] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Address/Addr.PostalCode)[1]', 'nvarchar(20)') AS [Addr.PostalCode] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/EMail)[1]', 'nvarchar(max)') AS [EMail] ,[Resume].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (/Resume/WebSite)[1]', 'nvarchar(max)') AS [WebSite] ,jc.[ModifiedDate] FROM [HumanResources].[JobCandidate] jc CROSS APPLY jc.[Resume].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/Resume"; /Resume') AS Resume(ref);

Tables Used in View Table Catalog AdventureWorks Table Schema HumanResources JobCandidate Table Name

Dependent Objects Dependent Obj JobCandidate USER_TABLE Dependent Obj Type

vJobCandidateEducation
Column Details Column Name Edu.Degree Edu.EndDate Edu.GPA Edu.GPAScale Edu.Level Edu.Loc.City Edu.Loc.CountryRegion Edu.Loc.State Edu.Major Edu.Minor Edu.School Edu.StartDate Data Type nvarchar datetime nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar datetime 5 5 -1 100 100 100 50 50 100 Length 50 Column Default Is Nullable YES YES YES YES YES YES YES YES YES YES YES YES Description

Column Name JobCandidateID int

Data Type

Length

Column Default

Is Nullable NO

Description

View Definition

View Definition CREATE VIEW [HumanResources].[vJobCandidateEducation] AS SELECT jc.[JobCandidateID] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Level)[1]', 'nvarchar(max)') AS [Edu.Level] ,CONVERT(datetime, REPLACE([Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.StartDate)[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [Edu.StartDate] ,CONVERT(datetime, REPLACE([Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.EndDate)[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [Edu.EndDate] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Degree)[1]', 'nvarchar(50)') AS [Edu.Degree] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Major)[1]', 'nvarchar(50)') AS [Edu.Major] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Minor)[1]', 'nvarchar(50)') AS [Edu.Minor] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.GPA)[1]', 'nvarchar(5)') AS [Edu.GPA] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.GPAScale)[1]', 'nvarchar(5)') AS [Edu.GPAScale] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.School)[1]', 'nvarchar(100)') AS [Edu.School] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Location/Location/Loc.CountryRegion)[1]', 'nvarchar(100)') AS [Edu.Loc.CountryRegion] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Location/Location/Loc.State)[1]', 'nvarchar(100)') AS [Edu.Loc.State] ,[Education].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Edu.Location/Location/Loc.City)[1]', 'nvarchar(100)') AS [Edu.Loc.City] FROM [HumanResources].[JobCandidate] jc CROSS APPLY jc.[Resume].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/Resume"; /Resume/Education') AS [Education](ref);

Tables Used in View Table Catalog AdventureWorks Table Schema HumanResources JobCandidate Table Name

Dependent Objects Dependent Obj JobCandidate USER_TABLE Dependent Obj Type

vJobCandidateEmployment
Column Details Column Name Emp.EndDate Emp.FunctionCategory Emp.IndustryCategory Emp.JobTitle Emp.Loc.City Emp.Loc.CountryRegion Emp.Loc.State Emp.OrgName Emp.Responsibility Emp.StartDate JobCandidateID Data Type datetime nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar datetime int -1 -1 100 -1 -1 -1 100 -1 Length Column Default Is Nullable YES YES YES YES YES YES YES YES YES YES NO Description

View Definition View Definition CREATE VIEW [HumanResources].[vJobCandidateEmployment] AS SELECT jc.[JobCandidateID] ,CONVERT(datetime, REPLACE([Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.StartDate)[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [Emp.StartDate] ,CONVERT(datetime, REPLACE([Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.EndDate)[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [Emp.EndDate] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.OrgName)[1]', 'nvarchar(100)') AS [Emp.OrgName] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.JobTitle)[1]', 'nvarchar(100)') AS [Emp.JobTitle] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.Responsibility)[1]', 'nvarchar(max)') AS [Emp.Responsibility] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.FunctionCategory)[1]', 'nvarchar(max)') AS [Emp.FunctionCategory] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.IndustryCategory)[1]', 'nvarchar(max)') AS [Emp.IndustryCategory] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.Location/Location/Loc.CountryRegion)[1]', 'nvarchar(max)') AS [Emp.Loc.CountryRegion] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.Location/Location/Loc.State)[1]', 'nvarchar(max)') AS [Emp.Loc.State] ,[Employment].ref.value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; (Emp.Location/Location/Loc.City)[1]', 'nvarchar(max)') AS [Emp.Loc.City] FROM [HumanResources].[JobCandidate] jc CROSS APPLY jc.[Resume].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/Resume"; /Resume/Employment') AS Employment(ref);

Tables Used in View Table Catalog AdventureWorks Table Schema HumanResources JobCandidate Table Name

Dependent Objects Dependent Obj JobCandidate USER_TABLE Dependent Obj Type

vAdditionalContactInfo
Column Details Column Name City ContactID CountryRegion EMailAddress EMailSpecialInstructions EMailTelephoneNumber Data Type nvarchar int nvarchar nvarchar nvarchar nvarchar 50 128 -1 50 50 -1 50 50 50 Length 50 Column Default Is Nullable YES NO YES YES YES YES NO YES NO YES NO YES Description

FirstName nvarchar HomeAddressSpecialInstructio nvarchar ns LastName nvarchar MiddleName ModifiedDate PostalCode nvarchar datetime nvarchar

Column Name rowguid StateProvince Street TelephoneNumber

Data Type uniqueidentifier nvarchar nvarchar nvarchar

Length

Column Default 50 50 50 -1

Is Nullable NO YES YES YES YES

Description

TelephoneSpecialInstructions nvarchar

View Definition

View Definition CREATE VIEW [Person].[vAdditionalContactInfo] AS SELECT [ContactID] ,[FirstName] ,[MiddleName] ,[LastName] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:telephoneNumber)[1]/act:number', 'nvarchar(50)') AS [TelephoneNumber] ,LTRIM(RTRIM([ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:telephoneNumber/act:SpecialInstructions/text())[1]', 'nvarchar(max)'))) AS [TelephoneSpecialInstructions] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:Street)[1]', 'nvarchar(50)') AS [Street] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:City)[1]', 'nvarchar(50)') AS [City] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:StateProvince)[1]', 'nvarchar(50)') AS [StateProvince] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:PostalCode)[1]', 'nvarchar(50)') AS [PostalCode] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:CountryRegion)[1]', 'nvarchar(50)') AS [CountryRegion] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:homePostalAddress/act:SpecialInstructions/text())[1]', 'nvarchar(max)') AS [HomeAddressSpecialInstructions] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:eMail/act:eMailAddress)[1]', 'nvarchar(128)') AS [EMailAddress] ,LTRIM(RTRIM([ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ContactInfo"; declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:eMail/act:SpecialInstructions/text())[1]', 'nvarchar(max)'))) AS [EMailSpecialInstructions] ,[ContactInfo].ref.value(N'declare namespace ci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo";

View Definition declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes"; (act:eMail/act:SpecialInstructions/act:telephoneNumber/act:number)[1]', 'nvarchar(50)') AS [EMailTelephoneNumber] ,[rowguid] ,[ModifiedDate] FROM [Person].[Contact] OUTER APPLY [AdditionalContactInfo].nodes(

Tables Used in View Table Catalog AdventureWorks Person Table Schema Contact Table Name

Dependent Objects Dependent Obj Contact USER_TABLE Dependent Obj Type

vStateProvinceCountryRegion
Column Details Column Name CountryRegionCode CountryRegionName IsOnlyStateProvinceFlag StateProvinceCode Data Type nvarchar nvarchar bit nchar 3 Length 3 50 Column Default Is Nullable NO NO NO NO Description

Column Name StateProvinceID StateProvinceName TerritoryID int

Data Type

Length

Column Default

Is Nullable NO

Description Clustered index on the view vStateProvinceCountryRegion.

nvarchar int

50

NO NO

View Definition View Definition CREATE VIEW [Person].[vStateProvinceCountryRegion] WITH SCHEMABINDING AS SELECT sp.[StateProvinceID] ,sp.[StateProvinceCode] ,sp.[IsOnlyStateProvinceFlag] ,sp.[Name] AS [StateProvinceName] ,sp.[TerritoryID] ,cr.[CountryRegionCode] ,cr.[Name] AS [CountryRegionName] FROM [Person].[StateProvince] sp INNER JOIN [Person].[CountryRegion] cr ON sp.[CountryRegionCode] = cr.[CountryRegionCode];

Tables Used in View Table Catalog AdventureWorks AdventureWorks Person Person Table Schema CountryRegion StateProvince Table Name

Dependent Objects Dependent Obj CountryRegion StateProvince USER_TABLE USER_TABLE Dependent Obj Type

vProductAndDescription
Column Details Column Name CultureID Description Name ProductID ProductModel Data Type nchar nvarchar nvarchar int nvarchar 50 Length 6 400 50 Column Default Is Nullable NO NO NO NO NO Clustered index on the view vProductAndDescription. Description

View Definition

View Definition CREATE VIEW [Production].[vProductAndDescription] WITH SCHEMABINDING AS -- View (indexed or standard) to display products and product descriptions by language. SELECT p.[ProductID] ,p.[Name] ,pm.[Name] AS [ProductModel] ,pmx.[CultureID] ,pd.[Description] FROM [Production].[Product] p INNER JOIN [Production].[ProductModel] pm ON p.[ProductModelID] = pm.[ProductModelID] INNER JOIN [Production].[ProductModelProductDescriptionCulture] pmx ON pm.[ProductModelID] = pmx.[ProductModelID] INNER JOIN [Production].[ProductDescription] pd ON pmx.[ProductDescriptionID] = pd.[ProductDescriptionID];

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks Table Schema Production Production Production Production Product ProductDescription ProductModel ProductModelProductDescriptionCulture Table Name

Dependent Objects Dependent Obj Product USER_TABLE Dependent Obj Type

Dependent Obj ProductDescription ProductModel ProductModelProductDescriptionCulture USER_TABLE USER_TABLE USER_TABLE

Dependent Obj Type

vProductModelCatalogDescription
Column Details Column Name BikeFrame Color Copyright Crankset MaintenanceDescription Manufacturer Material ModifiedDate Name NoOfYears Pedal PictureAngle PictureSize ProductLine ProductModelID ProductPhotoID Data Type nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar datetime nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar int nvarchar 256 50 256 256 256 256 256 Length -1 256 30 256 256 -1 256 Column Default Is Nullable YES YES YES YES YES YES YES NO NO YES YES YES YES YES NO YES Description

Column Name ProductURL RiderExperience rowguid Saddle Style Summary WarrantyDescription WarrantyPeriod Wheel

Data Type nvarchar nvarchar uniqueidentifier nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar

Length 256 1024 256 256 -1 256 256 256

Column Default

Is Nullable YES YES NO YES YES YES YES YES YES

Description

View Definition

View Definition CREATE VIEW [Production].[vProductModelCatalogDescription] AS SELECT [ProductModelID] ,[Name] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace html="http://www.w3.org/1999/xhtml"; (/p1:ProductDescription/p1:Summary/html:p)[1]', 'nvarchar(max)') AS [Summary] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; (/p1:ProductDescription/p1:Manufacturer/p1:Name)[1]', 'nvarchar(max)') AS [Manufacturer] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; (/p1:ProductDescription/p1:Manufacturer/p1:Copyright)[1]', 'nvarchar(30)') AS [Copyright] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; (/p1:ProductDescription/p1:Manufacturer/p1:ProductURL)[1]', 'nvarchar(256)') AS [ProductURL] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelWarrAndMain"; (/p1:ProductDescription/p1:Features/wm:Warranty/wm:WarrantyPeriod)[1]', 'nvarchar(256)') AS [WarrantyPeriod] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelWarrAndMain"; (/p1:ProductDescription/p1:Features/wm:Warranty/wm:Description)[1]', 'nvarchar(256)') AS [WarrantyDescription] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelWarrAndMain"; (/p1:ProductDescription/p1:Features/wm:Maintenance/wm:NoOfYears)[1]', 'nvarchar(256)') AS [NoOfYears] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wm="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelWarrAndMain"; (/p1:ProductDescription/p1:Features/wm:Maintenance/wm:Description)[1]', 'nvarchar(256)') AS [MaintenanceDescription] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wf="http://www.adventure-works.com/schemas/OtherFeatures"; (/p1:ProductDescription/p1:Features/wf:wheel)[1]', 'nvarchar(256)') AS [Wheel] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription";

View Definition declare namespace wf="http://www.adventure-works.com/schemas/OtherFeatures"; (/p1:ProductDescription/p1:Features/wf:saddle)[1]', 'nvarchar(256)') AS [Saddle] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wf="http://www.adventure-works.com/schemas/OtherFeatures"; (/p1:ProductDescription/p1:Features/wf:pedal)[1]', 'nvarchar(256)') AS [Pedal] ,[CatalogDescription].value(N'declare namespace p1="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelDescription"; declare namespace wf="http://www.adventure-works.com/schemas/OtherFeatures"; (/p1:ProductDescription/p1:Features/wf:BikeFrame)[1]', 'nvarchar(max)') AS [Bik

Tables Used in View Table Catalog AdventureWorks Table Schema Production ProductModel Table Name

Dependent Objects Dependent Obj ProductModel USER_TABLE Dependent Obj Type

vProductModelInstructions
Column Details Column Name Instructions LaborHours Data Type nvarchar decimal Length -1 Column Default Is Nullable YES YES Description

Column Name LocationID LotSize MachineHours ModifiedDate Name ProductModelID rowguid SetupHours Step int int

Data Type

Length

Column Default

Is Nullable YES YES YES NO

Description

decimal datetime nvarchar int uniqueidentifier decimal nvarchar 1024 50

NO NO NO YES YES

View Definition

View Definition CREATE VIEW [Production].[vProductModelInstructions] AS SELECT [ProductModelID] ,[Name] ,[Instructions].value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelManuInstructions"; (/root/text())[1]', 'nvarchar(max)') AS [Instructions] ,[MfgInstructions].ref.value('@LocationID[1]', 'int') AS [LocationID] ,[MfgInstructions].ref.value('@SetupHours[1]', 'decimal(9, 4)') AS [SetupHours] ,[MfgInstructions].ref.value('@MachineHours[1]', 'decimal(9, 4)') AS [MachineHours] ,[MfgInstructions].ref.value('@LaborHours[1]', 'decimal(9, 4)') AS [LaborHours] ,[MfgInstructions].ref.value('@LotSize[1]', 'int') AS [LotSize] ,[Steps].ref.value('string(.)[1]', 'nvarchar(1024)') AS [Step] ,[rowguid] ,[ModifiedDate] FROM [Production].[ProductModel] CROSS APPLY [Instructions].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelManuInstructions"; /root/Location') MfgInstructions(ref) CROSS APPLY [MfgInstructions].ref.nodes('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/ProductModelManuInstructions"; step') Steps(ref);

Tables Used in View Table Catalog AdventureWorks Table Schema Production ProductModel Table Name

Dependent Objects

Dependent Obj ProductModel USER_TABLE

Dependent Obj Type

vVendor
Column Details Column Name AddressLine1 AddressLine2 City ContactType CountryRegionName EmailAddress EmailPromotion FirstName LastName MiddleName Name Phone PostalCode StateProvinceName Suffix Title VendorID Data Type nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar int nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar int 50 50 50 50 25 15 50 10 8 Length 60 60 30 50 50 50 Column Default Is Nullable NO YES NO NO NO YES NO NO NO YES NO YES NO NO YES YES NO Description

View Definition View Definition CREATE VIEW [Purchasing].[vVendor] AS SELECT v.[VendorID] ,v.[Name] ,ct.[Name] AS [ContactType] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,[StateProvinceName] = sp.[Name] ,a.[PostalCode] ,[CountryRegionName] = cr.[Name] FROM [Purchasing].[Vendor] v INNER JOIN [Purchasing].[VendorContact] vc ON vc.[VendorID] = v.[VendorID] INNER JOIN [Person].[Contact] c ON c.[ContactID] = vc.[ContactID] INNER JOIN [Person].[ContactType] ct ON vc.[ContactTypeID] = ct.[ContactTypeID] INNER JOIN [Purchasing].[VendorAddress] va ON va.[VendorID] = v.[VendorID] INNER JOIN [Person].[Address] a ON a.[AddressID] = va.[AddressID] INNER JOIN [Person].[StateProvince] sp ON sp.[StateProvinceID] = a.[StateProvinceID] INNER JOIN [Person].[CountryRegion] cr ON cr.[CountryRegionCode] = sp.[CountryRegionCode];

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Person Person Person Person Person Purchasing Purchasing Purchasing Table Schema Address Contact ContactType CountryRegion StateProvince Vendor VendorAddress VendorContact Table Name

Dependent Objects Dependent Obj Address Contact ContactType CountryRegion StateProvince Vendor VendorAddress VendorContact USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vIndividualCustomer
Column Details Column Name AddressLine1 AddressLine2 AddressType City CountryRegionName CustomerID Demographics EmailAddress EmailPromotion FirstName LastName MiddleName Phone PostalCode StateProvinceName Suffix Title Data Type nvarchar nvarchar nvarchar nvarchar nvarchar int xml nvarchar int nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar 50 50 50 25 15 50 10 8 -1 50 Length 60 60 50 30 50 Column Default Is Nullable NO YES NO NO NO NO YES YES NO NO NO YES YES NO NO YES YES Description

View Definition View Definition CREATE VIEW [Sales].[vIndividualCustomer] AS SELECT i.[CustomerID] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,at.[Name] AS [AddressType] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,[StateProvinceName] = sp.[Name] ,a.[PostalCode] ,[CountryRegionName] = cr.[Name] ,i.[Demographics] FROM [Sales].[Individual] i INNER JOIN [Person].[Contact] c ON c.[ContactID] = i.[ContactID] INNER JOIN [Sales].[CustomerAddress] ca ON ca.[CustomerID] = i.[CustomerID] INNER JOIN [Person].[Address] a ON a.[AddressID] = ca.[AddressID] INNER JOIN [Person].[StateProvince] sp ON sp.[StateProvinceID] = a.[StateProvinceID] INNER JOIN [Person].[CountryRegion] cr ON cr.[CountryRegionCode] = sp.[CountryRegionCode] INNER JOIN [Person].[AddressType] at ON ca.[AddressTypeID] = at.[AddressTypeID] WHERE i.[CustomerID] IN (SELECT [Sales].[Customer].[CustomerID] FROM [Sales].[Customer] WHERE UPPER([Sales].[Customer].[CustomerType]) = 'I');

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Person Person Person Person Person Sales Sales Sales Table Schema Address AddressType Contact CountryRegion StateProvince Customer CustomerAddress Individual Table Name

Dependent Objects Dependent Obj Address AddressType Contact CountryRegion Customer CustomerAddress Individual StateProvince USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vIndividualDemographics
Column Details

Column Name BirthDate CustomerID DateFirstPurchase Education Gender HomeOwnerFlag MaritalStatus NumberCarsOwned NumberChildrenAtHome Occupation TotalChildren TotalPurchaseYTD YearlyIncome

Data Type datetime int datetime nvarchar nvarchar bit nvarchar int int nvarchar int money nvarchar

Length

Column Default

Is Nullable YES NO YES

Description

30 1 1

YES YES YES YES YES YES

30

YES YES YES

30

YES

View Definition

View Definition CREATE VIEW [Sales].[vIndividualDemographics] AS SELECT i.[CustomerID] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; TotalPurchaseYTD[1]', 'money') AS [TotalPurchaseYTD] ,CONVERT(datetime, REPLACE([IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; DateFirstPurchase[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [DateFirstPurchase] ,CONVERT(datetime, REPLACE([IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; BirthDate[1]', 'nvarchar(20)') ,'Z', ''), 101) AS [BirthDate] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; MaritalStatus[1]', 'nvarchar(1)') AS [MaritalStatus] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; YearlyIncome[1]', 'nvarchar(30)') AS [YearlyIncome] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; Gender[1]', 'nvarchar(1)') AS [Gender] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; TotalChildren[1]', 'integer') AS [TotalChildren] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; NumberChildrenAtHome[1]', 'integer') AS [NumberChildrenAtHome] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; Education[1]', 'nvarchar(30)') AS [Education] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; Occupation[1]', 'nvarchar(30)') AS [Occupation] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; HomeOwnerFlag[1]', 'bit') AS [HomeOwnerFlag] ,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; NumberCarsOwned[1]', 'integer') AS [NumberCarsOwned]

View Definition FROM [Sales].[Individual] i CROSS APPLY i.[Demographics].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; /IndividualSurvey') AS [IndividualSurvey](ref) WHERE [Demographics] IS NOT NULL;

Tables Used in View Table Catalog AdventureWorks Sales Table Schema Individual Table Name

Dependent Objects Dependent Obj Individual USER_TABLE Dependent Obj Type

vSalesPerson
Column Details Column Name AddressLine1 AddressLine2 City CountryRegionName EmailAddress Data Type nvarchar nvarchar nvarchar nvarchar nvarchar Length 60 60 30 50 50 Column Default Is Nullable NO YES NO NO YES Description

Column Name EmailPromotion FirstName JobTitle LastName MiddleName Phone PostalCode SalesLastYear SalesPersonID SalesQuota SalesYTD StateProvinceName Suffix TerritoryGroup TerritoryName Title int

Data Type

Length

Column Default 50 50 50 50 25 15

Is Nullable NO NO NO NO YES YES NO NO NO YES NO

Description

nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar money int money money nvarchar nvarchar nvarchar nvarchar nvarchar

50 10 50 50 8

NO YES YES YES YES

View Definition

View Definition CREATE VIEW [Sales].[vSalesPerson] AS SELECT s.[SalesPersonID] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,[JobTitle] = e.[Title] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,[StateProvinceName] = sp.[Name] ,a.[PostalCode] ,[CountryRegionName] = cr.[Name] ,[TerritoryName] = st.[Name] ,[TerritoryGroup] = st.[Group] ,s.[SalesQuota] ,s.[SalesYTD] ,s.[SalesLastYear] FROM [Sales].[SalesPerson] s INNER JOIN [HumanResources].[Employee] e ON e.[EmployeeID] = s.[SalesPersonID] LEFT OUTER JOIN [Sales].[SalesTerritory] st ON st.[TerritoryID] = s.[TerritoryID] INNER JOIN [Person].[Contact] c ON c.[ContactID] = e.[ContactID] INNER JOIN [HumanResources].[EmployeeAddress] ea ON e.[EmployeeID] = ea.[EmployeeID] INNER JOIN [Person].[Address] a ON ea.[AddressID] = a.[AddressID] INNER JOIN [Person].[StateProvince] sp ON sp.[StateProvinceID] = a.[StateProvinceID] INNER JOIN [Person].[CountryRegion] cr ON cr.[CountryRegionCode] = sp.[CountryRegionCode];

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Table Schema HumanResources HumanResources Person Person Person Person Sales Sales Employee EmployeeAddress Address Contact CountryRegion StateProvince SalesPerson SalesTerritory Table Name

Dependent Objects Dependent Obj Address Contact CountryRegion Employee EmployeeAddress SalesPerson SalesTerritory StateProvince USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vSalesPersonSalesByFiscalYears
Column Details Column Name 2002 2003 2004 FullName SalesPersonID SalesTerritory Title Data Type money money money nvarchar int nvarchar nvarchar 50 50 152 Length Column Default Is Nullable YES YES YES YES YES NO NO Description

View Definition

View Definition CREATE VIEW [Sales].[vSalesPersonSalesByFiscalYears] AS SELECT pvt.[SalesPersonID] ,pvt.[FullName] ,pvt.[Title] ,pvt.[SalesTerritory] ,pvt.[2002] ,pvt.[2003] ,pvt.[2004] FROM (SELECT soh.[SalesPersonID] ,c.[FirstName] + ' ' + COALESCE(c.[MiddleName], '') + ' ' + c.[LastName] AS [FullName] ,e.[Title] ,st.[Name] AS [SalesTerritory] ,soh.[SubTotal] ,YEAR(DATEADD(m, 6, soh.[OrderDate])) AS [FiscalYear] FROM [Sales].[SalesPerson] sp INNER JOIN [Sales].[SalesOrderHeader] soh ON sp.[SalesPersonID] = soh.[SalesPersonID] INNER JOIN [Sales].[SalesTerritory] st ON sp.[TerritoryID] = st.[TerritoryID] INNER JOIN [HumanResources].[Employee] e ON soh.[SalesPersonID] = e.[EmployeeID] INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.ContactID ) AS soh PIVOT ( SUM([SubTotal]) FOR [FiscalYear] IN ([2002], [2003], [2004]) ) AS pvt;

Tables Used in View

Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Person Sales Sales Sales

Table Schema HumanResources Employee Contact SalesOrderHeader SalesPerson SalesTerritory

Table Name

Dependent Objects Dependent Obj Contact Employee SalesOrderHeader SalesPerson SalesTerritory USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

vStoreWithDemographics
Column Details Column Name AddressLine1 AddressLine2 AddressType AnnualRevenue AnnualSales Data Type nvarchar nvarchar nvarchar money money Length 60 60 50 Column Default Is Nullable NO YES NO YES YES Description

Column Name BankName Brands BusinessType City ContactType CountryRegionName CustomerID EmailAddress EmailPromotion FirstName Internet LastName MiddleName Name NumberEmployees Phone PostalCode Specialty SquareFeet StateProvinceName Suffix Title YearOpened

Data Type nvarchar nvarchar nvarchar nvarchar nvarchar nvarchar int nvarchar int nvarchar nvarchar nvarchar nvarchar nvarchar int nvarchar nvarchar nvarchar int nvarchar nvarchar nvarchar int

Length 50 30 5 30 50 50 50 50 30 50 50 50 25 15 50 50 10 8

Column Default

Is Nullable YES YES YES NO NO NO NO YES NO NO YES NO YES NO YES YES NO YES YES NO YES YES YES

Description

View Definition

View Definition CREATE VIEW [Sales].[vStoreWithDemographics] AS SELECT s.[CustomerID] ,s.[Name] ,ct.[Name] AS [ContactType] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,at.[Name] AS [AddressType] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,sp.[Name] AS [StateProvinceName] ,a.[PostalCode] ,cr.[Name] AS [CountryRegionName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/AnnualSales)[1]', 'money') AS [AnnualSales] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/AnnualRevenue)[1]', 'money') AS [AnnualRevenue] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/BankName)[1]', 'nvarchar(50)') AS [BankName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/BusinessType)[1]', 'nvarchar(5)') AS [BusinessType] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/YearOpened)[1]', 'integer') AS [YearOpened] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/Specialty)[1]', 'nvarchar(50)') AS [Specialty] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey";

View Definition (/StoreSurvey/SquareFeet)[1]', 'integer') AS [SquareFeet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/Brands)[1]', 'nvarchar(30)') AS [Brands] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/Internet)[1]', 'nvarchar(30)') AS [Internet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/StoreSurvey"; (/StoreSurvey/NumberEmployees)[1]', 'integer') AS [NumberEmployees] FROM [Sales].[Store] s INNER JOIN [Sales].[StoreContact] sc ON sc.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Contact] c ON c.[ContactID] = sc.[ContactID] INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] INNER JOIN [Sales].[CustomerAddress] ca ON ca.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Address] a ON a.[AddressID] = ca.[AddressID] INNER JOIN [Person].[StateProvince] sp ON sp.[StateProvinceID] = a.[StateProvinceID] INNER JOIN [Person].[CountryRegion] cr ON cr.[CountryRegionCode] = sp.[CountryRegionCode] INNER JOIN [Person].[AddressType] at ON ca.[AddressTypeID] = at.[AddressTypeID] WHERE s.[CustomerID] IN (SELECT [Sales].[Customer].[CustomerID] FROM [Sales].[Customer] WHERE UPPER([Sales].[Customer].[CustomerType]) = 'S');

Tables Used in View Table Catalog AdventureWorks AdventureWorks AdventureWorks Person Person Person Table Schema Address AddressType Contact Table Name

Table Catalog AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks AdventureWorks Person Person Person Sales Sales Sales Sales

Table Schema ContactType CountryRegion StateProvince Customer CustomerAddress Store StoreContact

Table Name

Dependent Objects Dependent Obj Address AddressType Contact ContactType CountryRegion Customer CustomerAddress StateProvince Store StoreContact USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

Procedures
Procedure Name uspPrintError uspLogError uspGetBillOfMaterials uspGetEmployeeManagers uspGetManagerEmployees uspGetWhereUsedProductID uspUpdateEmployeeHireInfo uspUpdateEmployeeLogin uspUpdateEmployeePersonalInfo dbo dbo dbo dbo dbo dbo HumanResources HumanResources HumanResources Procedure Schema

uspPrintError
Definition

Routine Definition -- uspPrintError prints 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. CREATE PROCEDURE [dbo].[uspPrintError] AS BEGIN SET NOCOUNT ON; -- Print error information. PRINT 'Error ' + CONVERT(varchar(50), ERROR_NUMBER()) + ', Severity ' + CONVERT(varchar(5), ERROR_SEVERITY()) + ', State ' + CONVERT(varchar(5), ERROR_STATE()) + ', Procedure ' + ISNULL(ERROR_PROCEDURE(), '-') + ', Line ' + CONVERT(varchar(5), ERROR_LINE()); PRINT ERROR_MESSAGE(); END;

Dependent Objects Dependent Obj uspLogError dVendor iduSalesOrderDetail iPurchaseOrderDetail iStore iWorkOrder uPurchaseOrderDetail uPurchaseOrderHeader uSalesOrderHeader SQL_STORED_PROCEDURE SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER Dependent Obj Type

Dependent Obj uWorkOrder SQL_TRIGGER

Dependent Obj Type

uspLogError
Definition

Routine Definition -- uspLogError logs error information in the ErrorLog table about the -- error that caused execution to jump to the CATCH block of a -- TRY...CATCH construct. This should be executed from within the scope -- of a CATCH block otherwise it will return without inserting error -- information. CREATE PROCEDURE [dbo].[uspLogError] @ErrorLogID [int] = 0 OUTPUT -- contains the ErrorLogID of the row inserted AS -- by uspLogError in the ErrorLog table BEGIN SET NOCOUNT ON; -- Output parameter value of 0 indicates that error -- information was not logged SET @ErrorLogID = 0; BEGIN TRY -- Return if there is no error information to log IF ERROR_NUMBER() IS NULL RETURN; -- Return if inside an uncommittable transaction. -- Data insertion/modification is not allowed when -- a transaction is in an uncommittable state. IF XACT_STATE() = -1 BEGIN PRINT 'Cannot log error since the current transaction is in an uncommittable state. ' + 'Rollback the transaction before executing uspLogError in order to successfully log error information.'; RETURN; END INSERT [dbo].[ErrorLog] ( [UserName], [ErrorNumber], [ErrorSeverity], [ErrorState], [ErrorProcedure], [ErrorLine], [ErrorMessage] )

Routine Definition VALUES ( CONVERT(sysname, CURRENT_USER), ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_STATE(), ERROR_PROCEDURE(), ERROR_LINE(), ERROR_MESSAGE() ); -- Pass back the ErrorLogID of the row inserted SET @ErrorLogID = @@IDENTITY; END TRY BEGIN CATCH PRINT 'An error occurred in stored procedure uspLogError: '; EXECUTE [dbo].[uspPrintError]; RETURN -1; END CATCH END;

Dependent Objects Dependent Obj uspPrintError uspUpdateEmployeeHireInfo uspUpdateEmployeeLogin uspUpdateEmployeePersonalInfo dVendor iduSalesOrderDetail iPurchaseOrderDetail iStore SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER Dependent Obj Type

Dependent Obj iWorkOrder uPurchaseOrderDetail uPurchaseOrderHeader uSalesOrderHeader uWorkOrder ErrorLog SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER SQL_TRIGGER USER_TABLE

Dependent Obj Type

uspGetBillOfMaterials
Definition

Routine Definition CREATE PROCEDURE [dbo].[uspGetBillOfMaterials] @StartProductID [int], @CheckDate [datetime] AS BEGIN SET NOCOUNT ON; -- Use recursive query to generate a multi-level Bill of Material (i.e. all level 1 -- components of a level 0 assembly, all level 2 components of a level 1 assembly) -- The CheckDate eliminates any components that are no longer used in the product on this date. WITH [BOM_cte]([ProductAssemblyID], [ComponentID], [ComponentDesc], [PerAssemblyQty], [StandardCost], [ListPrice], [BOMLevel], [RecursionLevel]) -- CTE name and columns AS ( SELECT b.[ProductAssemblyID], b.[ComponentID], p.[Name], b.[PerAssemblyQty], p.[StandardCost], p.[ListPrice], b.[BOMLevel], 0 -- Get the initial list of components for the bike assembly FROM [Production].[BillOfMaterials] b INNER JOIN [Production].[Product] p ON b.[ComponentID] = p.[ProductID] WHERE b.[ProductAssemblyID] = @StartProductID AND @CheckDate >= b.[StartDate] AND @CheckDate <= ISNULL(b.[EndDate], @CheckDate) UNION ALL SELECT b.[ProductAssemblyID], b.[ComponentID], p.[Name], b.[PerAssemblyQty], p.[StandardCost], p.[ListPrice], b.[BOMLevel], [RecursionLevel] + 1 -- Join recursive member to anchor FROM [BOM_cte] cte INNER JOIN [Production].[BillOfMaterials] b ON b.[ProductAssemblyID] = cte.[ComponentID] INNER JOIN [Production].[Product] p ON b.[ComponentID] = p.[ProductID] WHERE @CheckDate >= b.[StartDate] AND @CheckDate <= ISNULL(b.[EndDate], @CheckDate) ) -- Outer select from the CTE SELECT b.[ProductAssemblyID], b.[ComponentID], b.[ComponentDesc], SUM(b.[PerAssemblyQty]) AS [TotalQuantity] , b.[StandardCost], b.[ListPrice], b.[BOMLevel], b.[RecursionLevel] FROM [BOM_cte] b GROUP BY b.[ComponentID], b.[ComponentDesc], b.[ProductAssemblyID], b.[BOMLevel], b.[RecursionLevel], b.[StandardCost], b.[ListPrice] ORDER BY b.[BOMLevel], b.[ProductAssemblyID], b.[ComponentID] OPTION (MAXRECURSION 25) END;

Dependent Objects Dependent Obj BillOfMaterials Product USER_TABLE USER_TABLE Dependent Obj Type

uspGetEmployeeManagers
Definition

Routine Definition CREATE PROCEDURE [dbo].[uspGetEmployeeManagers] @EmployeeID [int] AS BEGIN SET NOCOUNT ON; -- Use recursive query to list out all Employees required for a particular Manager WITH [EMP_cte]([EmployeeID], [ManagerID], [FirstName], [LastName], [Title], [RecursionLevel]) -- CTE name and columns AS ( SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], e.[Title], 0 -- Get the initial Employee FROM [HumanResources].[Employee] e INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] WHERE e.[EmployeeID] = @EmployeeID UNION ALL SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], e.[Title], [RecursionLevel] + 1 -- Join recursive member to anchor FROM [HumanResources].[Employee] e INNER JOIN [EMP_cte] ON e.[EmployeeID] = [EMP_cte].[ManagerID] INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] ) -- Join back to Employee to return the manager name SELECT [EMP_cte].[RecursionLevel], [EMP_cte].[EmployeeID], [EMP_cte].[FirstName], [EMP_cte].[LastName], [EMP_cte].[ManagerID], c.[FirstName] AS 'ManagerFirstName', c.[LastName] AS 'ManagerLastName' -- Outer select from the CTE FROM [EMP_cte] INNER JOIN [HumanResources].[Employee] e ON [EMP_cte].[ManagerID] = e.[EmployeeID] INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] ORDER BY [RecursionLevel], [ManagerID], [EmployeeID] OPTION (MAXRECURSION 25) END;

Dependent Objects

Dependent Obj Contact Employee USER_TABLE USER_TABLE

Dependent Obj Type

uspGetManagerEmployees
Definition

Routine Definition CREATE PROCEDURE [dbo].[uspGetManagerEmployees] @ManagerID [int] AS BEGIN SET NOCOUNT ON; -- Use recursive query to list out all Employees required for a particular Manager WITH [EMP_cte]([EmployeeID], [ManagerID], [FirstName], [LastName], [RecursionLevel]) -- CTE name and columns AS ( SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], 0 -- Get the initial list of Employees for Manager n FROM [HumanResources].[Employee] e INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] WHERE [ManagerID] = @ManagerID UNION ALL SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], [RecursionLevel] + 1 -- Join recursive member to anchor FROM [HumanResources].[Employee] e INNER JOIN [EMP_cte] ON e.[ManagerID] = [EMP_cte].[EmployeeID] INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] ) -- Join back to Employee to return the manager name SELECT [EMP_cte].[RecursionLevel], [EMP_cte].[ManagerID], c.[FirstName] AS 'ManagerFirstName', c.[LastName] AS 'ManagerLastName', [EMP_cte].[EmployeeID], [EMP_cte].[FirstName], [EMP_cte].[LastName] -- Outer select from the CTE FROM [EMP_cte] INNER JOIN [HumanResources].[Employee] e ON [EMP_cte].[ManagerID] = e.[EmployeeID] INNER JOIN [Person].[Contact] c ON e.[ContactID] = c.[ContactID] ORDER BY [RecursionLevel], [ManagerID], [EmployeeID] OPTION (MAXRECURSION 25) END;

Dependent Objects

Dependent Obj Contact Employee USER_TABLE USER_TABLE

Dependent Obj Type

uspGetWhereUsedProductID
Definition

Routine Definition CREATE PROCEDURE [dbo].[uspGetWhereUsedProductID] @StartProductID [int], @CheckDate [datetime] AS BEGIN SET NOCOUNT ON; --Use recursive query to generate a multi-level Bill of Material (i.e. all level 1 components of a level 0 assembly, all level 2 components of a level 1 assembly) WITH [BOM_cte]([ProductAssemblyID], [ComponentID], [ComponentDesc], [PerAssemblyQty], [StandardCost], [ListPrice], [BOMLevel], [RecursionLevel]) -- CTE name and columns AS ( SELECT b.[ProductAssemblyID], b.[ComponentID], p.[Name], b.[PerAssemblyQty], p.[StandardCost], p.[ListPrice], b.[BOMLevel], 0 -- Get the initial list of components for the bike assembly FROM [Production].[BillOfMaterials] b INNER JOIN [Production].[Product] p ON b.[ProductAssemblyID] = p.[ProductID] WHERE b.[ComponentID] = @StartProductID AND @CheckDate >= b.[StartDate] AND @CheckDate <= ISNULL(b.[EndDate], @CheckDate) UNION ALL SELECT b.[ProductAssemblyID], b.[ComponentID], p.[Name], b.[PerAssemblyQty], p.[StandardCost], p.[ListPrice], b.[BOMLevel], [RecursionLevel] + 1 -- Join recursive member to anchor FROM [BOM_cte] cte INNER JOIN [Production].[BillOfMaterials] b ON cte.[ProductAssemblyID] = b.[ComponentID] INNER JOIN [Production].[Product] p ON b.[ProductAssemblyID] = p.[ProductID] WHERE @CheckDate >= b.[StartDate] AND @CheckDate <= ISNULL(b.[EndDate], @CheckDate) ) -- Outer select from the CTE SELECT b.[ProductAssemblyID], b.[ComponentID], b.[ComponentDesc], SUM(b.[PerAssemblyQty]) AS [TotalQuantity] , b.[StandardCost], b.[ListPrice], b.[BOMLevel], b.[RecursionLevel] FROM [BOM_cte] b GROUP BY b.[ComponentID], b.[ComponentDesc], b.[ProductAssemblyID], b.[BOMLevel], b.[RecursionLevel], b.[StandardCost], b.[ListPrice] ORDER BY b.[BOMLevel], b.[ProductAssemblyID], b.[ComponentID] OPTION (MAXRECURSION 25) END;

Dependent Objects Dependent Obj BillOfMaterials Product USER_TABLE USER_TABLE Dependent Obj Type

uspUpdateEmployeeHireInfo
Definition

Routine Definition CREATE PROCEDURE [HumanResources].[uspUpdateEmployeeHireInfo] @EmployeeID [int], @Title [nvarchar](50), @HireDate [datetime], @RateChangeDate [datetime], @Rate [money], @PayFrequency [tinyint], @CurrentFlag [dbo].[Flag] WITH EXECUTE AS CALLER AS BEGIN SET NOCOUNT ON; BEGIN TRY BEGIN TRANSACTION; UPDATE [HumanResources].[Employee] SET [Title] = @Title ,[HireDate] = @HireDate ,[CurrentFlag] = @CurrentFlag WHERE [EmployeeID] = @EmployeeID; INSERT INTO [HumanResources].[EmployeePayHistory] ([EmployeeID] ,[RateChangeDate] ,[Rate] ,[PayFrequency]) VALUES (@EmployeeID, @RateChangeDate, @Rate, @PayFrequency); COMMIT TRANSACTION; END TRY BEGIN CATCH -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError];

Routine Definition END CATCH; END;

Dependent Objects Dependent Obj uspLogError Employee EmployeePayHistory SQL_STORED_PROCEDURE USER_TABLE USER_TABLE Dependent Obj Type

uspUpdateEmployeeLogin
Definition

Routine Definition CREATE PROCEDURE [HumanResources].[uspUpdateEmployeeLogin] @EmployeeID [int], @ManagerID [int], @LoginID [nvarchar](256), @Title [nvarchar](50), @HireDate [datetime], @CurrentFlag [dbo].[Flag] WITH EXECUTE AS CALLER AS BEGIN SET NOCOUNT ON; BEGIN TRY UPDATE [HumanResources].[Employee] SET [ManagerID] = @ManagerID ,[LoginID] = @LoginID ,[Title] = @Title ,[HireDate] = @HireDate ,[CurrentFlag] = @CurrentFlag WHERE [EmployeeID] = @EmployeeID; END TRY BEGIN CATCH EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError Employee SQL_STORED_PROCEDURE USER_TABLE Dependent Obj Type

uspUpdateEmployeePersonalInfo
Definition Routine Definition CREATE PROCEDURE [HumanResources].[uspUpdateEmployeePersonalInfo] @EmployeeID [int], @NationalIDNumber [nvarchar](15), @BirthDate [datetime], @MaritalStatus [nchar](1), @Gender [nchar](1) WITH EXECUTE AS CALLER AS BEGIN SET NOCOUNT ON; BEGIN TRY UPDATE [HumanResources].[Employee] SET [NationalIDNumber] = @NationalIDNumber ,[BirthDate] = @BirthDate ,[MaritalStatus] = @MaritalStatus ,[Gender] = @Gender WHERE [EmployeeID] = @EmployeeID; END TRY BEGIN CATCH EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError Employee SQL_STORED_PROCEDURE USER_TABLE Dependent Obj Type

Functions
Function Name ufnLeadingZeros ufnGetAccountingStartDate ufnGetAccountingEndDate ufnGetContactInformation ufnGetProductDealerPrice ufnGetProductListPrice ufnGetProductStandardCost ufnGetStock ufnGetDocumentStatusText ufnGetPurchaseOrderStatusText ufnGetSalesOrderStatusText dbo dbo dbo dbo dbo dbo dbo dbo dbo dbo dbo Function Schema

ufnLeadingZeros
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnLeadingZeros]( @Value int ) RETURNS varchar(8) WITH SCHEMABINDING AS BEGIN DECLARE @ReturnValue varchar(8); SET @ReturnValue = CONVERT(varchar(8), @Value); SET @ReturnValue = REPLICATE('0', 8 - DATALENGTH(@ReturnValue)) + @ReturnValue; RETURN (@ReturnValue); END;

Dependent Objects Dependent Obj Customer USER_TABLE Dependent Obj Type

ufnGetAccountingStartDate
Definition Routine Definition CREATE FUNCTION [dbo].[ufnGetAccountingStartDate]() RETURNS [datetime] AS BEGIN RETURN CONVERT(datetime, '20030701', 112); END;

Dependent Objects ---None---

ufnGetAccountingEndDate
Definition Routine Definition CREATE FUNCTION [dbo].[ufnGetAccountingEndDate]() RETURNS [datetime] AS BEGIN RETURN DATEADD(millisecond, -2, CONVERT(datetime, '20040701', 112)); END;

Dependent Objects ---None---

ufnGetContactInformation
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetContactInformation](@ContactID int) RETURNS @retContactInformation TABLE ( -- Columns returned by the function [ContactID] int PRIMARY KEY NOT NULL, [FirstName] [nvarchar](50) NULL, [LastName] [nvarchar](50) NULL, [JobTitle] [nvarchar](50) NULL, [ContactType] [nvarchar](50) NULL ) AS -- Returns the first name, last name, job title and contact type for the specified contact. BEGIN DECLARE @FirstName [nvarchar](50), @LastName [nvarchar](50), @JobTitle [nvarchar](50), @ContactType [nvarchar](50); -- Get common contact information SELECT @ContactID = ContactID, @FirstName = FirstName, @LastName = LastName FROM [Person].[Contact] WHERE [ContactID] = @ContactID; SET @JobTitle = CASE -- Check for employee WHEN EXISTS(SELECT * FROM [HumanResources].[Employee] e WHERE e.[ContactID] = @ContactID) THEN (SELECT [Title] FROM [HumanResources].[Employee] WHERE [ContactID] = @ContactID) -- Check for vendor WHEN EXISTS(SELECT * FROM [Purchasing].[VendorContact] vc INNER JOIN [Person].[ContactType] ct ON vc.[ContactTypeID] = ct.[ContactTypeID]

Routine Definition WHERE vc.[ContactID] = @ContactID) THEN (SELECT ct.[Name] FROM [Purchasing].[VendorContact] vc INNER JOIN [Person].[ContactType] ct ON vc.[ContactTypeID] = ct.[ContactTypeID] WHERE vc.[ContactID] = @ContactID) -- Check for store WHEN EXISTS(SELECT * FROM [Sales].[StoreContact] sc INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] WHERE sc.[ContactID] = @ContactID) THEN (SELECT ct.[Name] FROM [Sales].[StoreContact] sc INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] WHERE [ContactID] = @ContactID) ELSE NULL END; SET @ContactType = CASE -- Check for employee WHEN EXISTS(SELECT * FROM [HumanResources].[Employee] e WHERE e.[ContactID] = @ContactID) THEN 'Employee' -- Check for vendor WHEN EXISTS(SELECT * FROM [Purchasing].[VendorContact] vc INNER JOIN [Person].[ContactType] ct ON vc.[ContactTypeID] = ct.[ContactTypeID] WHERE vc.[ContactID] = @ContactID) THEN 'Vendor Contact' -- Check for store WHEN EXISTS(SELECT * FROM [Sales].[StoreContact] sc INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] WHERE sc.[ContactID] = @ContactID) THEN 'Store Contact'

Routine Definition -- Check for individual consumer WHEN EXISTS(SELECT * FROM [Sales].[Individual] i WHERE i.[ContactID] = @ContactID) THEN 'Consumer' END; -- Return the information to the caller IF @ContactID IS NOT NULL BEGIN INSERT @retContactInformation SELECT @ContactID, @FirstName, @LastName, @JobTitle, @ContactType; END; RETURN; END;

Dependent Objects Dependent Obj Contact ContactType Employee Individual StoreContact VendorContact USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

ufnGetProductDealerPrice
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetProductDealerPrice](@ProductID [int], @OrderDate [datetime]) RETURNS [money] AS -- Returns the dealer price for the product on a specific date. BEGIN DECLARE @DealerPrice money; DECLARE @DealerDiscount money; SET @DealerDiscount = 0.60 -- 60% of list price SELECT @DealerPrice = plph.[ListPrice] * @DealerDiscount FROM [Production].[Product] p INNER JOIN [Production].[ProductListPriceHistory] plph ON p.[ProductID] = plph.[ProductID] AND p.[ProductID] = @ProductID AND @OrderDate BETWEEN plph.[StartDate] AND COALESCE(plph.[EndDate], CONVERT(datetime, '99991231', 112)); -- Make sure we get all the prices! RETURN @DealerPrice; END;

Dependent Objects Dependent Obj Product ProductListPriceHistory USER_TABLE USER_TABLE Dependent Obj Type

ufnGetProductListPrice
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetProductListPrice](@ProductID [int], @OrderDate [datetime]) RETURNS [money] AS BEGIN DECLARE @ListPrice money; SELECT @ListPrice = plph.[ListPrice] FROM [Production].[Product] p INNER JOIN [Production].[ProductListPriceHistory] plph ON p.[ProductID] = plph.[ProductID] AND p.[ProductID] = @ProductID AND @OrderDate BETWEEN plph.[StartDate] AND COALESCE(plph.[EndDate], CONVERT(datetime, '99991231', 112)); -- Make sure we get all the prices! RETURN @ListPrice; END;

Dependent Objects Dependent Obj Product ProductListPriceHistory USER_TABLE USER_TABLE Dependent Obj Type

ufnGetProductStandardCost
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetProductStandardCost](@ProductID [int], @OrderDate [datetime]) RETURNS [money] AS -- Returns the standard cost for the product on a specific date. BEGIN DECLARE @StandardCost money; SELECT @StandardCost = pch.[StandardCost] FROM [Production].[Product] p INNER JOIN [Production].[ProductCostHistory] pch ON p.[ProductID] = pch.[ProductID] AND p.[ProductID] = @ProductID AND @OrderDate BETWEEN pch.[StartDate] AND COALESCE(pch.[EndDate], CONVERT(datetime, '99991231', 112)); -- Make sure we get all the prices! RETURN @StandardCost; END;

Dependent Objects Dependent Obj Product ProductCostHistory USER_TABLE USER_TABLE Dependent Obj Type

ufnGetStock
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int]) RETURNS [int] AS -- Returns the stock level for the product. This function is used internally only BEGIN DECLARE @ret int; SELECT @ret = SUM(p.[Quantity]) FROM [Production].[ProductInventory] p WHERE p.[ProductID] = @ProductID AND p.[LocationID] = '6'; -- Only look at inventory in the misc storage IF (@ret IS NULL) SET @ret = 0 RETURN @ret END;

Dependent Objects Dependent Obj ProductInventory USER_TABLE Dependent Obj Type

ufnGetDocumentStatusText
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetDocumentStatusText](@Status [tinyint]) RETURNS [nvarchar](16) AS -- Returns the sales order status text representation for the status value. BEGIN DECLARE @ret [nvarchar](16); SET @ret = CASE @Status WHEN 1 THEN N'Pending approval' WHEN 2 THEN N'Approved' WHEN 3 THEN N'Obsolete' ELSE N'** Invalid **' END; RETURN @ret END;

Dependent Objects ---None---

ufnGetPurchaseOrderStatusText
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetPurchaseOrderStatusText](@Status [tinyint]) RETURNS [nvarchar](15) AS -- Returns the sales order status text representation for the status value. BEGIN DECLARE @ret [nvarchar](15); SET @ret = CASE @Status WHEN 1 THEN 'Pending' WHEN 2 THEN 'Approved' WHEN 3 THEN 'Rejected' WHEN 4 THEN 'Complete' ELSE '** Invalid **' END; RETURN @ret END;

Dependent Objects ---None---

ufnGetSalesOrderStatusText
Definition

Routine Definition CREATE FUNCTION [dbo].[ufnGetSalesOrderStatusText](@Status [tinyint]) RETURNS [nvarchar](15) AS -- Returns the sales order status text representation for the status value. BEGIN DECLARE @ret [nvarchar](15); SET @ret = CASE @Status WHEN 1 THEN 'In process' WHEN 2 THEN 'Approved' WHEN 3 THEN 'Backordered' WHEN 4 THEN 'Rejected' WHEN 5 THEN 'Shipped' WHEN 6 THEN 'Cancelled' ELSE '** Invalid **' END; RETURN @ret END;

Dependent Objects ---None---

Indexes
Table Name Address Index Name Column Name Index Type NONCLUS TERED Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true false false false false false

AK_Address_r rowguid owguid

Table Name

Index Name IX_Address_A ddressLine1_A ddressLine2_C ity_StateProvin ceID_PostalCo de IX_Address_A ddressLine1_A ddressLine2_C ity_StateProvin ceID_PostalCo de IX_Address_A ddressLine1_A ddressLine2_C ity_StateProvin ceID_PostalCo de IX_Address_A ddressLine1_A ddressLine2_C ity_StateProvin ceID_PostalCo de IX_Address_A ddressLine1_A ddressLine2_C ity_StateProvin ceID_PostalCo de IX_Address_St ateProvinceID PK_Address_A ddressID AK_AddressTy pe_Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal

Address

AddressLin NONCLUS e1 TERED

true

false

false

false

false

false

Address

AddressLin NONCLUS e2 TERED

true

false

false

false

false

false

Address

City

NONCLUS TERED

true

false

false

false

false

false

Address

StateProvi NONCLUS nceID TERED

true

false

false

false

false

false

Address

PostalCod NONCLUS e TERED StateProvi NONCLUS nceID TERED AddressID CLUSTER ED NONCLUS Name TERED

true

false

false

false

false

false

Address Address AddressType

false true true

false true false

false false false

false false false

false false false

false false false

Table Name AddressType AddressType AWBuildVersion

Index Name AK_AddressTy pe_rowguid PK_AddressTy pe_AddressTy peID PK_AWBuildV ersion_SystemI nformationID AK_BillOfMater ials_ProductAs semblyID_Com ponentID_Start Date AK_BillOfMater ials_ProductAs semblyID_Com ponentID_Start Date AK_BillOfMater ials_ProductAs semblyID_Com ponentID_Start Date IX_BillOfMateri als_UnitMeasu reCode PK_BillOfMater ials_BillOfMate rialsID AK_Contact_ro wguid IX_Contact_E mailAddress PK_Contact_C ontactID

Column Name rowguid

Index Type NONCLUS TERED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true false true true false false false false false false false false false false false false

AddressTy CLUSTER peID ED SystemInfo CLUSTER rmationID ED ProductAs CLUSTER semblyID ED

BillOfMaterials

true

false

false

false

false

false

BillOfMaterials

Componen CLUSTER tID ED

true

false

false

false

false

false

BillOfMaterials

StartDate

CLUSTER ED

true

false

false

false

false

false

BillOfMaterials BillOfMaterials Contact Contact Contact

UnitMeasu NONCLUS reCode TERED BillOfMater NONCLUS ialsID TERED NONCLUS TERED EmailAddr NONCLUS ess TERED ContactID CLUSTER ED rowguid

false true true false true

false true false false true

false false false false false

false false false false false

false false false false false

false false false false false

Table Name Contact

Index Name

Column Name

Index Type XML CLUSTER ED CLUSTER ED NONCLUS TERED CLUSTER ED NONCLUS TERED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false false false false false false

ContactCreditCard

ContactCreditCard ContactType ContactType CountryRegion CountryRegion CountryRegionCurrency

PXML_Contact Additional _AddContact ContactInf o PK_ContactCr editCard_Cont ContactID actID_CreditCa rdID PK_ContactCr editCard_Cont CreditCard actID_CreditCa ID rdID AK_ContactTy Name pe_Name PK_ContactTy ContactTy pe_ContactTyp peID eID AK_CountryRe gion_Name PK_CountryRe gion_CountryR egionCode IX_CountryReg ionCurrency_C urrencyCode PK_CountryRe gionCurrency_ CountryRegion Code_Currenc yCode PK_CountryRe gionCurrency_ CountryRegion Code_Currenc yCode AK_CreditCard _CardNumber Name

true

true

false

false

false

false

true true true true true false

true false true false true false

false false false false false false

false false false false false false

false false false false false false

false false false false false false

CountryRe CLUSTER gionCode ED CurrencyC NONCLUS ode TERED CountryRe CLUSTER gionCode ED

CountryRegionCurrency

true

true

false

false

false

false

CountryRegionCurrency

CurrencyC CLUSTER ode ED CardNumb NONCLUS er TERED

true

true

false

false

false

false

CreditCard

true

false

false

false

false

false

Table Name CreditCard Culture Culture Currency Currency

Index Name PK_CreditCard _CreditCardID AK_Culture_N ame PK_Culture_C ultureID AK_Currency_ Name PK_Currency_ CurrencyCode AK_CurrencyR ate_CurrencyR ateDate_From CurrencyCode _ToCurrencyC ode AK_CurrencyR ate_CurrencyR ateDate_From CurrencyCode _ToCurrencyC ode AK_CurrencyR ate_CurrencyR ateDate_From CurrencyCode _ToCurrencyC ode PK_CurrencyR ate_CurrencyR ateID AK_Customer_ AccountNumbe r AK_Customer_ rowguid

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true false true false true false false false false false false false false false false false false false false false false false false false false

CreditCard CLUSTER ID ED NONCLUS Name TERED CultureID CLUSTER ED NONCLUS Name TERED CurrencyC CLUSTER ode ED CurrencyR NONCLUS ateDate TERED

CurrencyRate

true

false

false

false

false

false

CurrencyRate

FromCurre NONCLUS ncyCode TERED

true

false

false

false

false

false

CurrencyRate

ToCurrenc NONCLUS yCode TERED

true

false

false

false

false

false

CurrencyRate Customer Customer

CurrencyR CLUSTER ateID ED AccountNu NONCLUS mber TERED rowguid NONCLUS TERED

true true true

true false false

false false false

false false false

false false false

false false false

Table Name Customer Customer CustomerAddress

Index Name IX_Customer_ TerritoryID PK_Customer_ CustomerID AK_CustomerA ddress_rowgui d PK_CustomerA ddress_Custo merID_Addres sID PK_CustomerA ddress_Custo merID_Addres sID PK_DatabaseL og_DatabaseL ogID AK_Departmen t_Name PK_Departmen t_DepartmentI D AK_Document _FileName_Re vision AK_Document _FileName_Re vision PK_Document _DocumentID AK_Employee_ LoginID

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false true true false true false false false false false false false false false false false false false

TerritoryID NONCLUS TERED CustomerI CLUSTER D ED rowguid NONCLUS TERED

CustomerAddress

CustomerI CLUSTER D ED AddressID CLUSTER ED DatabaseL NONCLUS ogID TERED Name NONCLUS TERED

true

true

false

false

false

false

CustomerAddress

true

true

false

false

false

false

DatabaseLog Department Department Document Document Document Employee

true true true true true true true

true false true false false true false

false false false false false false false

false false false false false false false

false false false false false false false

false false false false false false false

Departmen CLUSTER tID ED FileName Revision NONCLUS TERED NONCLUS TERED

DocumentI CLUSTER D ED NONCLUS LoginID TERED

Table Name Employee

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false true true false false false true false false false false false false false false false false false false false false false false false false false false false

AK_Employee_ NationalIDNum ber AK_Employee_ Employee rowguid IX_Employee_ Employee ManagerID PK_Employee_ Employee EmployeeID AK_Employee EmployeeAddress Address_rowg uid PK_Employee Address_Empl EmployeeAddress oyeeID_Addres sID PK_Employee Address_Empl EmployeeAddress oyeeID_Addres sID IX_EmployeeD EmployeeDepartmentHistory epartmentHisto ry_DepartmentI D IX_EmployeeD EmployeeDepartmentHistory epartmentHisto ry_ShiftID PK_Employee DepartmentHis EmployeeDepartmentHistory tory_Employee ID_StartDate_ DepartmentID

NationalID NONCLUS Number TERED NONCLUS TERED ManagerID NONCLUS TERED EmployeeI CLUSTER D ED rowguid rowguid NONCLUS TERED

EmployeeI CLUSTER D ED AddressID CLUSTER ED Departmen NONCLUS tID TERED ShiftID NONCLUS TERED

true

true

false

false

false

false

true

true

false

false

false

false

false

false

false

false

false

false

false

false

false

false

false

false

EmployeeI CLUSTER D ED

true

true

false

false

false

false

Table Name

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false

PK_Employee DepartmentHis EmployeeDepartmentHistory tory_Employee ID_StartDate_ DepartmentID PK_Employee DepartmentHis EmployeeDepartmentHistory tory_Employee ID_StartDate_ DepartmentID PK_Employee DepartmentHis EmployeeDepartmentHistory tory_Employee ID_StartDate_ DepartmentID PK_Employee PayHistory_Em EmployeePayHistory ployeeID_Rate ChangeDate PK_Employee PayHistory_Em EmployeePayHistory ployeeID_Rate ChangeDate PK_ErrorLog_ ErrorLog ErrorLogID PK_Illustration Illustration _IllustrationID PK_Individual_ Individual CustomerID PXML_Individu Individual al_Demographi cs XMLPATH_Indi Individual vidual_Demogr aphics

Departmen CLUSTER tID ED

ShiftID

CLUSTER ED

true

true

false

false

false

false

StartDate

CLUSTER ED

true

true

false

false

false

false

EmployeeI CLUSTER D ED RateChang CLUSTER eDate ED ErrorLogID CLUSTER ED IllustrationI CLUSTER D ED CustomerI CLUSTER D ED Demograp XML hics Demograp XML hics

true

true

false

false

false

false

true true true true false false

true true true true false false

false false false false false false

false false false false false false

false false false false false false

false false false false false false

Table Name Individual Individual JobCandidate JobCandidate Location Location Product Product Product Product ProductCategory ProductCategory ProductCategory

Index Name XMLPROPERT Y_Individual_D emographics XMLVALUE_In dividual_Demo graphics IX_JobCandida te_EmployeeID PK_JobCandid ate_JobCandid ateID AK_Location_ Name PK_Location_L ocationID AK_Product_N ame AK_Product_Pr oductNumber AK_Product_ro wguid PK_Product_Pr oductID AK_ProductCat egory_Name AK_ProductCat egory_rowguid PK_ProductCat egory_Product CategoryID PK_ProductCo stHistory_Prod uctID_StartDat e

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false false false true true true true true true true true true true false false false true false true false false false true false false true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

Demograp XML hics Demograp XML hics EmployeeI NONCLUS D TERED JobCandid CLUSTER ateID ED NONCLUS TERED LocationID CLUSTER ED NONCLUS Name TERED ProductNu NONCLUS mber TERED NONCLUS rowguid TERED ProductID CLUSTER ED NONCLUS Name TERED NONCLUS rowguid TERED Name ProductCat CLUSTER egoryID ED ProductID CLUSTER ED

ProductCostHistory

true

true

false

false

false

false

Table Name

Index Name PK_ProductCo stHistory_Prod uctID_StartDat e AK_ProductDe scription_rowg uid PK_ProductDe scription_Prod uctDescriptionI D PK_ProductDo cument_Produ ctID_Document ID PK_ProductDo cument_Produ ctID_Document ID PK_ProductInv entory_Product ID_LocationID PK_ProductInv entory_Product ID_LocationID PK_ProductList PriceHistory_P roductID_Start Date PK_ProductList PriceHistory_P roductID_Start Date AK_ProductMo del_Name

Column Name StartDate

Index Type CLUSTER ED NONCLUS TERED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false

ProductCostHistory

ProductDescription

rowguid

true

false

false

false

false

false

ProductDescription

ProductDe CLUSTER scriptionID ED ProductID CLUSTER ED DocumentI CLUSTER D ED ProductID CLUSTER ED LocationID CLUSTER ED ProductID CLUSTER ED CLUSTER ED NONCLUS TERED

true

true

false

false

false

false

ProductDocument

true

true

false

false

false

false

ProductDocument

true

true

false

false

false

false

ProductInventory ProductInventory

true true

true true

false false

false false

false false

false false

ProductListPriceHistory

true

true

false

false

false

false

ProductListPriceHistory ProductModel

StartDate Name

true true

true false

false false

false false

false false

false false

Table Name ProductModel

Index Name

Column Name rowguid

Index Type NONCLUS TERED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false true false false false false false false false false false false false false false false false false false false

AK_ProductMo del_rowguid PK_ProductMo ProductModel del_ProductMo delID PXML_Product ProductModel Model_Catalog Description PXML_Product ProductModel Model_Instructi ons PK_ProductMo delIllustration_ ProductModelIllustration ProductModelI D_IllustrationID PK_ProductMo delIllustration_ ProductModelIllustration ProductModelI D_IllustrationID PK_ProductMo delProductDes ProductModelProductDescrip criptionCulture _ProductModel tionCulture ID_ProductDes criptionID_Cult ureID PK_ProductMo delProductDes ProductModelProductDescrip criptionCulture _ProductModel tionCulture ID_ProductDes criptionID_Cult ureID

ProductMo CLUSTER delID ED CatalogDe XML scription Instruction XML s ProductMo CLUSTER delID ED IllustrationI CLUSTER D ED

true

true

false

false

false

false

true

true

false

false

false

false

ProductMo CLUSTER delID ED

true

true

false

false

false

false

ProductDe CLUSTER scriptionID ED

true

true

false

false

false

false

Table Name

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal

PK_ProductMo delProductDes ProductModelProductDescrip criptionCulture _ProductModel tionCulture ID_ProductDes criptionID_Cult ureID PK_ProductPh ProductPhoto oto_ProductPh otoID PK_ProductPro ductPhoto_Pro ProductProductPhoto ductID_Product PhotoID PK_ProductPro ductPhoto_Pro ProductProductPhoto ductID_Product PhotoID IX_ProductRev ProductReview iew_ProductID _Name IX_ProductRev ProductReview iew_ProductID _Name IX_ProductRev ProductReview iew_ProductID _Name PK_ProductRe ProductReview view_ProductR eviewID AK_ProductSu ProductSubcategory bcategory_Na me AK_ProductSu ProductSubcategory bcategory_row guid

CultureID

CLUSTER ED

true

true

false

false

false

false

ProductPh CLUSTER otoID ED ProductID NONCLUS TERED ProductPh NONCLUS otoID TERED ProductID NONCLUS TERED ReviewerN NONCLUS ame TERED Comments NONCLUS TERED ProductRe CLUSTER viewID ED Name rowguid NONCLUS TERED NONCLUS TERED

true

true

false

false

false

false

true

true

false

false

false

false

true

true

false

false

false

false

false false false true true true

false false false true false false

false false false false false false

false false false false false false

false false false false false false

false false false false false false

Table Name

Index Name PK_ProductSu bcategory_Pro ductSubcatego ryID IX_ProductVen dor_UnitMeasu reCode IX_ProductVen dor_VendorID PK_ProductVe ndor_ProductI D_VendorID PK_ProductVe ndor_ProductI D_VendorID IX_PurchaseOr derDetail_Prod uctID PK_PurchaseO rderDetail_Pur chaseOrderID_ PurchaseOrder DetailID PK_PurchaseO rderDetail_Pur chaseOrderID_ PurchaseOrder DetailID IX_PurchaseOr derHeader_Em ployeeID IX_PurchaseOr derHeader_Ve ndorID

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false

ProductSubcategory

ProductSu CLUSTER bcategoryI ED D UnitMeasu NONCLUS reCode TERED VendorID NONCLUS TERED

ProductVendor ProductVendor ProductVendor ProductVendor PurchaseOrderDetail

false false true true false

false false true true false

false false false false false

false false false false false

false false false false false

false false false false false

ProductID CLUSTER ED VendorID CLUSTER ED

ProductID NONCLUS TERED PurchaseO CLUSTER rderID ED

PurchaseOrderDetail

true

true

false

false

false

false

PurchaseOrderDetail

PurchaseO CLUSTER rderDetailI ED D EmployeeI NONCLUS D TERED VendorID NONCLUS TERED

true

true

false

false

false

false

PurchaseOrderHeader PurchaseOrderHeader

false false

false false

false false

false false

false false

false false

Table Name PurchaseOrderHeader

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

PK_PurchaseO rderHeader_Pu rchaseOrderID queue_messages_19770580 queue_clustere 79 d_index queue_messages_19770580 queue_clustere 79 d_index

PurchaseO CLUSTER rderID ED status

CLUSTER ED queuing_or CLUSTER der ED queue_messages_19770580 queue_clustere conversati CLUSTER on_group_i ED 79 d_index d queue_messages_19770580 79 queue_messages_19770580 79 queue_messages_19770580 79 queue_messages_19770580 79 conversati CLUSTER on_handle ED NONCLUS status TERED NONCLUS priority TERED queuing_or NONCLUS der TERED queue_messages_19770580 queue_second conversati NONCLUS on_group_i TERED 79 ary_index d queue_messages_19770580 79 queue_messages_19770580 79 queue_messages_20090581 93 queue_messages_20090581 93 conversati NONCLUS on_handle TERED service_id NONCLUS TERED CLUSTER status ED queuing_or CLUSTER der ED queue_messages_20090581 queue_clustere conversati CLUSTER on_group_i ED 93 d_index d queue_messages_20090581 queue_clustere conversati CLUSTER 93 d_index on_handle ED queue_second ary_index queue_second ary_index queue_clustere d_index queue_clustere d_index queue_clustere d_index queue_second ary_index queue_second ary_index queue_second ary_index

Table Name queue_messages_20090581 93 queue_messages_20090581 93 queue_messages_20090581 93

Index Name queue_second ary_index queue_second ary_index queue_second ary_index

Column Name status

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

NONCLUS TERED NONCLUS priority TERED queuing_or NONCLUS der TERED queue_messages_20090581 queue_second conversati NONCLUS on_group_i TERED 93 ary_index d queue_messages_20090581 93 queue_messages_20090581 93 queue_messages_20410583 07 queue_messages_20410583 07 conversati NONCLUS on_handle TERED service_id NONCLUS TERED CLUSTER status ED queuing_or CLUSTER der ED queue_messages_20410583 queue_clustere conversati CLUSTER on_group_i ED 07 d_index d queue_messages_20410583 07 queue_messages_20410583 07 queue_messages_20410583 07 queue_messages_20410583 07 conversati CLUSTER on_handle ED NONCLUS status TERED NONCLUS priority TERED queuing_or NONCLUS der TERED queue_messages_20410583 queue_second conversati NONCLUS on_group_i TERED 07 ary_index d queue_messages_20410583 queue_second conversati NONCLUS 07 ary_index on_handle TERED queue_clustere d_index queue_second ary_index queue_second ary_index queue_second ary_index queue_second ary_index queue_second ary_index queue_clustere d_index queue_clustere d_index

Table Name

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false false false false false false false false false false false false false

queue_messages_20410583 queue_second service_id NONCLUS 07 ary_index TERED AK_SalesOrde NONCLUS SalesOrderDetail rDetail_rowgui rowguid TERED d IX_SalesOrder Detail_ProductI D PK_SalesOrde rDetail_SalesO SalesOrderDetail rderID_SalesO rderDetailID PK_SalesOrde rDetail_SalesO SalesOrderDetail rderID_SalesO rderDetailID AK_SalesOrde SalesOrderHeader rHeader_rowgu id AK_SalesOrde SalesOrderHeader rHeader_Sales OrderNumber IX_SalesOrder SalesOrderHeader Header_Custo merID IX_SalesOrder SalesOrderHeader Header_Sales PersonID PK_SalesOrde SalesOrderHeader rHeader_Sales OrderID PK_SalesOrde SalesOrderHeaderSalesReas rHeaderSalesR eason_SalesOr on derID_SalesRe asonID SalesOrderDetail ProductID NONCLUS TERED SalesOrder CLUSTER ID ED SalesOrder CLUSTER DetailID ED rowguid NONCLUS TERED

true

true

false

false

false

false

true

true

false

false

false

false

true true false false true

false false false false true

false false false false false

false false false false false

false false false false false

false false false false false

SalesOrder NONCLUS Number TERED CustomerI NONCLUS D TERED SalesPers NONCLUS onID TERED SalesOrder CLUSTER ID ED SalesOrder CLUSTER ID ED

true

true

false

false

false

false

Table Name

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false

PK_SalesOrde SalesOrderHeaderSalesReas rHeaderSalesR eason_SalesOr on derID_SalesRe asonID AK_SalesPers SalesPerson on_rowguid PK_SalesPers SalesPerson on_SalesPerso nID AK_SalesPers SalesPersonQuotaHistory onQuotaHistor y_rowguid PK_SalesPers onQuotaHistor SalesPersonQuotaHistory y_SalesPerson ID_QuotaDate PK_SalesPers onQuotaHistor SalesPersonQuotaHistory y_SalesPerson ID_QuotaDate PK_SalesReas SalesReason on_SalesReas onID AK_SalesTaxR SalesTaxRate ate_rowguid AK_SalesTaxR ate_StateProvi SalesTaxRate nceID_TaxTyp e AK_SalesTaxR ate_StateProvi SalesTaxRate nceID_TaxTyp e

SalesReas CLUSTER onID ED rowguid NONCLUS TERED

true true true

false true false

false false false

false false false

false false false

false false false

SalesPers CLUSTER onID ED rowguid NONCLUS TERED

SalesPers CLUSTER onID ED QuotaDate CLUSTER ED SalesReas CLUSTER onID ED rowguid NONCLUS TERED

true

true

false

false

false

false

true

true

false

false

false

false

true true true

true false false

false false false

false false false

false false false

false false false

StateProvi NONCLUS nceID TERED NONCLUS TERED

TaxType

true

false

false

false

false

false

Table Name SalesTaxRate SalesTerritory SalesTerritory SalesTerritory SalesTerritoryHistory

Index Name PK_SalesTaxR ate_SalesTaxR ateID AK_SalesTerrit ory_Name AK_SalesTerrit ory_rowguid PK_SalesTerrit ory_TerritoryID AK_SalesTerrit oryHistory_row guid PK_SalesTerrit oryHistory_Sal esPersonID_St artDate_Territo ryID PK_SalesTerrit oryHistory_Sal esPersonID_St artDate_Territo ryID PK_SalesTerrit oryHistory_Sal esPersonID_St artDate_Territo ryID AK_ScrapReas on_Name PK_ScrapReas on_ScrapReas onID AK_Shift_Nam e AK_Shift_Start Time_EndTime

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true false false true false false false false false false false false false false false false false false false false false false false false false

SalesTaxR CLUSTER ateID ED NONCLUS TERED NONCLUS rowguid TERED TerritoryID CLUSTER ED Name rowguid NONCLUS TERED

SalesTerritoryHistory

SalesPers CLUSTER onID ED

true

true

false

false

false

false

SalesTerritoryHistory

TerritoryID CLUSTER ED

true

true

false

false

false

false

SalesTerritoryHistory

StartDate

CLUSTER ED NONCLUS TERED

true

true

false

false

false

false

ScrapReason ScrapReason Shift Shift

Name

true true true true

false true false false

false false false false

false false false false

false false false false

false false false false

ScrapReas CLUSTER onID ED Name StartTime NONCLUS TERED NONCLUS TERED

Table Name Shift Shift ShipMethod ShipMethod ShipMethod

Index Name AK_Shift_Start Time_EndTime PK_Shift_ShiftI D AK_ShipMetho d_Name AK_ShipMetho d_rowguid PK_ShipMetho d_ShipMethodI D IX_ShoppingC artItem_Shoppi ngCartID_Prod uctID IX_ShoppingC artItem_Shoppi ngCartID_Prod uctID PK_ShoppingC artItem_Shoppi ngCartItemID AK_SpecialOff er_rowguid PK_SpecialOff er_SpecialOffe rID AK_SpecialOff erProduct_row guid IX_SpecialOffe rProduct_Prod uctID

Column Name EndTime ShiftID Name rowguid

Index Type NONCLUS TERED CLUSTER ED NONCLUS TERED NONCLUS TERED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true false true false false true false false false false false false false false false false false false false false false false false false false false

ShipMetho CLUSTER dID ED ShoppingC NONCLUS artID TERED ProductID NONCLUS TERED ShoppingC CLUSTER artItemID ED rowguid NONCLUS TERED

ShoppingCartItem

false

false

false

false

false

false

ShoppingCartItem

false

false

false

false

false

false

ShoppingCartItem SpecialOffer SpecialOffer SpecialOfferProduct SpecialOfferProduct

true true true true false

true false true false false

false false false false false

false false false false false

false false false false false

false false false false false

SpecialOff CLUSTER erID ED rowguid NONCLUS TERED

ProductID NONCLUS TERED

Table Name

Index Name PK_SpecialOff erProduct_Spe cialOfferID_Pro ductID PK_SpecialOff erProduct_Spe cialOfferID_Pro ductID AK_StateProvi nce_Name AK_StateProvi nce_rowguid AK_StateProvi nce_StateProvi nceCode_Cou ntryRegionCod e AK_StateProvi nce_StateProvi nceCode_Cou ntryRegionCod e PK_StateProvi nce_StateProvi nceID AK_Store_row guid IX_Store_Sale sPersonID PK_Store_Cust omerID PXML_Store_ Demographics AK_StoreCont act_rowguid

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true false false false false

SpecialOfferProduct

SpecialOff CLUSTER erID ED ProductID CLUSTER ED Name rowguid NONCLUS TERED NONCLUS TERED

SpecialOfferProduct StateProvince StateProvince

true true true

true false false

false false false

false false false

false false false

false false false

StateProvince

StateProvi NONCLUS nceCode TERED

true

false

false

false

false

false

StateProvince

CountryRe NONCLUS gionCode TERED StateProvi CLUSTER nceID ED NONCLUS TERED SalesPers NONCLUS onID TERED CustomerI CLUSTER D ED Demograp XML hics NONCLUS rowguid TERED rowguid

true

false

false

false

false

false

StateProvince Store Store Store Store StoreContact

true true false true false true

true false false true false false

false false false false false false

false false false false false false

false false false false false false

false false false false false false

Table Name StoreContact StoreContact StoreContact StoreContact sysallocunits sysasymkeys sysasymkeys sysasymkeys sysbinobjs sysbinobjs sysbinobjs sysbinobjs sysbinobjs sysbinsubobjs sysbinsubobjs

Index Name IX_StoreConta ct_ContactID IX_StoreConta ct_ContactTyp eID PK_StoreCont act_CustomerI D_ContactID PK_StoreCont act_CustomerI D_ContactID clust cl nc1 nc3 clst clst nc1 nc1 nc1 clst clst

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false false true true true true true true true true true true true true true false false true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

ContactID NONCLUS TERED ContactTy NONCLUS peID TERED CustomerI CLUSTER D ED ContactID CLUSTER ED CLUSTER ED CLUSTER id ED NONCLUS name TERED thumbprint NONCLUS TERED CLUSTER class ED CLUSTER id ED NONCLUS class TERED NONCLUS nsid TERED NONCLUS name TERED CLUSTER class ED CLUSTER idmajor ED auid

Table Name sysbinsubobjs sysbinsubobjs sysbinsubobjs sysbinsubobjs syscerts syscerts syscerts syscerts syscerts sysclsobjs sysclsobjs sysclsobjs sysclsobjs syscolpars syscolpars syscolpars syscolpars

Index Name clst nc1 nc1 nc1 cl nc1 nc2 nc2 nc3 clst clst nc nc clst clst clst nc

Column Name subid

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

CLUSTER ED NONCLUS name TERED NONCLUS idmajor TERED NONCLUS class TERED CLUSTER id ED NONCLUS name TERED NONCLUS issuer TERED NONCLUS snum TERED thumbprint NONCLUS TERED CLUSTER class ED CLUSTER id ED NONCLUS name TERED NONCLUS class TERED CLUSTER id ED CLUSTER number ED CLUSTER colid ED NONCLUS name TERED

Table Name syscolpars syscolpars sysconvgroup sysdbfiles sysdbfiles sysdercv sysdercv sysdesend sysftinds sysguidrefs sysguidrefs sysguidrefs sysguidrefs sysguidrefs syshobtcolumns syshobtcolumns syshobts

Index Name nc nc clst clst clst cl cl cl clst cl cl cl nc nc clust clust clust

Column Name id

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

NONCLUS TERED NONCLUS number TERED CLUSTER id ED CLUSTER dbid ED CLUSTER fileid ED CLUSTER diagid ED CLUSTER initiator ED CLUSTER handle ED CLUSTER id ED CLUSTER class ED CLUSTER id ED CLUSTER subid ED NONCLUS guid TERED NONCLUS class TERED CLUSTER hobtid ED hobtcolum CLUSTER nid ED CLUSTER hobtid ED

Table Name sysidxstats sysidxstats sysidxstats sysidxstats sysiscols sysiscols sysiscols sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs sysmultiobjrefs

Index Name clst clst nc nc clst clst clst clst clst clst clst clst nc1 nc1 nc1 nc1 nc1

Column Name id

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

CLUSTER ED CLUSTER indid ED NONCLUS name TERED NONCLUS id TERED CLUSTER idmajor ED CLUSTER idminor ED CLUSTER subid ED CLUSTER class ED CLUSTER depid ED depsubid CLUSTER ED CLUSTER indepid ED indepsubid CLUSTER ED NONCLUS indepid TERED NONCLUS class TERED indepsubid NONCLUS TERED NONCLUS depid TERED depsubid NONCLUS TERED

Table Name sysnsobjs sysnsobjs sysnsobjs sysnsobjs sysnsobjs sysobjkeycrypts sysobjkeycrypts sysobjkeycrypts sysobjvalues sysobjvalues sysobjvalues sysobjvalues sysowners sysowners sysowners sysowners sysprivs

Index Name clst clst nc nc nc cl cl cl clst clst clst clst clst nc1 nc2 nc2 clust

Column Name class

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

CLUSTER ED CLUSTER id ED NONCLUS name TERED NONCLUS nsid TERED NONCLUS class TERED CLUSTER class ED CLUSTER id ED thumbprint CLUSTER ED CLUSTER valclass ED CLUSTER objid ED CLUSTER subobjid ED CLUSTER valnum ED CLUSTER id ED NONCLUS name TERED NONCLUS sid TERED NONCLUS id TERED CLUSTER class ED

Table Name sysprivs sysprivs sysprivs sysprivs sysprivs sysqnames sysqnames sysqnames sysqnames sysremsvcbinds sysremsvcbinds sysremsvcbinds sysremsvcbinds sysrowsetcolumns sysrowsetcolumns sysrowsetrefs sysrowsetrefs

Index Name clust clust clust clust clust clst clst clst nc1 clst nc1 nc2 nc2 clust clust clust clust

Column Name id

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

CLUSTER ED CLUSTER subid ED CLUSTER grantee ED CLUSTER grantor ED CLUSTER type ED CLUSTER qid ED CLUSTER hash ED CLUSTER nid ED NONCLUS nid TERED CLUSTER id ED NONCLUS name TERED NONCLUS scid TERED NONCLUS remsvc TERED CLUSTER rowsetid ED rowsetcolid CLUSTER ED CLUSTER class ED CLUSTER objid ED

Table Name sysrowsetrefs sysrowsetrefs sysrowsets sysrts sysrts sysrts sysrts sysrts sysscalartypes sysscalartypes sysscalartypes sysscalartypes sysscalartypes sysschobjs sysschobjs sysschobjs sysschobjs

Index Name clust clust clust clst nc1 nc1 nc1 nc2 clst nc1 nc1 nc2 nc2 clst nc1 nc1 nc1

Column Name indexid

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

CLUSTER ED rowsetnum CLUSTER ED CLUSTER rowsetid ED CLUSTER id ED NONCLUS remsvc TERED NONCLUS brkrinst TERED NONCLUS id TERED NONCLUS name TERED CLUSTER id ED NONCLUS schid TERED NONCLUS name TERED NONCLUS name TERED NONCLUS schid TERED CLUSTER id ED NONCLUS nsclass TERED NONCLUS nsid TERED NONCLUS name TERED

Table Name sysschobjs sysschobjs sysschobjs sysschobjs sysschobjs sysserefs sysserefs sysserefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssingleobjrefs syssqlguides

Index Name nc2 nc2 nc2 nc3 nc3 clust clust clust clst clst clst nc1 nc1 nc1 nc1 nc1 clst

Column Name name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true false false true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

NONCLUS TERED NONCLUS nsid TERED NONCLUS nsclass TERED NONCLUS pid TERED NONCLUS pclass TERED CLUSTER class ED CLUSTER depid ED CLUSTER indepid ED CLUSTER class ED CLUSTER depid ED depsubid CLUSTER ED NONCLUS indepid TERED NONCLUS class TERED indepsubid NONCLUS TERED NONCLUS depid TERED depsubid NONCLUS TERED CLUSTER id ED

Table Name syssqlguides syssqlguides syssqlguides syssqlguides syssqlguides systypedsubobjs systypedsubobjs systypedsubobjs systypedsubobjs systypedsubobjs systypedsubobjs sysxmitqueue sysxmitqueue sysxmitqueue sysxmlcomponent sysxmlcomponent sysxmlcomponent

Index Name nc1 nc2 nc2 nc2 nc2 clst clst clst nc nc nc clst clst clst cl nc1 nc1

Column Name name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

NONCLUS TERED scopetype NONCLUS TERED NONCLUS scopeid TERED NONCLUS hash TERED NONCLUS id TERED CLUSTER class ED CLUSTER idmajor ED CLUSTER subid ED NONCLUS name TERED NONCLUS idmajor TERED NONCLUS class TERED CLUSTER dlgid ED CLUSTER finitiator ED msgseqnu CLUSTER m ED CLUSTER id ED NONCLUS xsdid TERED NONCLUS uriord TERED

Table Name sysxmlcomponent sysxmlcomponent sysxmlcomponent sysxmlcomponent sysxmlfacet sysxmlfacet sysxmlplacement sysxmlplacement sysxmlplacement sysxmlplacement sysxmlplacement sysxprops sysxprops sysxprops sysxprops TransactionHistory

Index Name nc1 nc1 nc1 nc1 cl cl cl cl nc1 nc1 nc1 clust clust clust clust

Column Name qual

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true true true true true true true true true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

NONCLUS TERED NONCLUS nameid TERED symspace NONCLUS TERED nmscope NONCLUS TERED CLUSTER compid ED CLUSTER ord ED placingid CLUSTER ED CLUSTER ordinal ED NONCLUS placedid TERED placingid NONCLUS TERED NONCLUS ordinal TERED CLUSTER class ED CLUSTER id ED CLUSTER subid ED CLUSTER name ED

IX_Transaction History_Produc ProductID NONCLUS TERED tID

Table Name

Index Name IX_Transaction History_Refere nceOrderID_R eferenceOrder LineID IX_Transaction History_Refere nceOrderID_R eferenceOrder LineID PK_Transactio nHistory_Trans actionID IX_Transaction HistoryArchive _ProductID IX_Transaction HistoryArchive _ReferenceOrd erID_Referenc eOrderLineID IX_Transaction HistoryArchive _ReferenceOrd erID_Referenc eOrderLineID PK_Transactio nHistoryArchiv e_TransactionI D PK__ufnGetCo ntactInf__6008 3D91 AK_UnitMeasu re_Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false false false false false false

TransactionHistory

Reference NONCLUS OrderID TERED

TransactionHistory

Reference NONCLUS OrderLineI TERED D Transactio CLUSTER nID ED ProductID NONCLUS TERED Reference NONCLUS OrderID TERED

false

false

false

false

false

false

TransactionHistory TransactionHistoryArchive

true false

true false

false false

false false

false false

false false

TransactionHistoryArchive

false

false

false

false

false

false

TransactionHistoryArchive

Reference NONCLUS OrderLineI TERED D Transactio CLUSTER nID ED ContactID CLUSTER ED Name NONCLUS TERED

false

false

false

false

false

false

TransactionHistoryArchive

true

true

false

false

false

false

ufnGetContactInformation UnitMeasure

true true

true false

false false

false false

false false

false false

Table Name UnitMeasure

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true false true true false false true true true true true true false true false true true false false true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

PK_UnitMeasu re_UnitMeasur eCode AK_Vendor_Ac Vendor countNumber PK_Vendor_V Vendor endorID IX_VendorAddr VendorAddress ess_AddressID PK_VendorAd VendorAddress dress_VendorI D_AddressID PK_VendorAd VendorAddress dress_VendorI D_AddressID IX_VendorCont VendorContact act_ContactID IX_VendorCont VendorContact act_ContactTy peID PK_VendorCo VendorContact ntact_VendorI D_ContactID PK_VendorCo VendorContact ntact_VendorI D_ContactID IX_vProductAn vProductAndDescription dDescription IX_vProductAn vProductAndDescription dDescription vStateProvinceCountryRegio IX_vStateProvi nceCountryRe n gion

UnitMeasu CLUSTER reCode ED AccountNu NONCLUS mber TERED VendorID CLUSTER ED AddressID NONCLUS TERED VendorID CLUSTER ED

AddressID CLUSTER ED ContactID NONCLUS TERED ContactTy NONCLUS peID TERED VendorID CLUSTER ED

ContactID CLUSTER ED ProductID CLUSTER ED CultureID CLUSTER ED StateProvi CLUSTER nceID ED

Table Name

Index Name

Column Name

Index Type

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true false false true false false false false true false false false false false false false false false false false false false false false false false false false false false

vStateProvinceCountryRegio IX_vStateProvi CountryRe CLUSTER nceCountryRe gionCode ED n gion IX_WorkOrder ProductID NONCLUS WorkOrder _ProductID TERED IX_WorkOrder ScrapReas NONCLUS WorkOrder _ScrapReasonI onID TERED D PK_WorkOrder _WorkOrderID IX_WorkOrder WorkOrderRouting Routing_Produ ctID PK_WorkOrder Routing_Work WorkOrderRouting OrderID_Produ ctID_Operation Sequence PK_WorkOrder Routing_Work WorkOrderRouting OrderID_Produ ctID_Operation Sequence PK_WorkOrder Routing_Work WorkOrderRouting OrderID_Produ ctID_Operation Sequence xml_index_nodes_12695795 PXML_Individu al_Demographi 61_32000 cs xml_index_nodes_12695795 PXML_Individu al_Demographi 61_32000 cs WorkOrder WorkOrder CLUSTER ID ED ProductID NONCLUS TERED WorkOrder CLUSTER ID ED

true

true

false

false

false

false

ProductID CLUSTER ED

true

true

false

false

false

false

OperationS CLUSTER equence ED CLUSTER ED CLUSTER ED

true

true

false

false

false

false

id pk1

true true

false false

false false

false false

false false

false false

Table Name

Index Name

Column Name

Index Type NONCLUS TERED NONCLUS TERED NONCLUS TERED NONCLUS TERED NONCLUS TERED NONCLUS TERED NONCLUS TERED CLUSTER ED CLUSTER ED CLUSTER ED CLUSTER ED CLUSTER ED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal false false false false false false false true true true true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false

xml_index_nodes_12695795 XMLPATH_Indi hid vidual_Demogr 61_32000 aphics xml_index_nodes_12695795 XMLPATH_Indi value vidual_Demogr 61_32000 aphics xml_index_nodes_12695795 XMLPROPERT pk1 Y_Individual_D 61_32000 emographics xml_index_nodes_12695795 XMLPROPERT hid Y_Individual_D 61_32000 emographics xml_index_nodes_12695795 XMLPROPERT value Y_Individual_D 61_32000 emographics xml_index_nodes_12695795 XMLVALUE_In value dividual_Demo 61_32000 graphics xml_index_nodes_12695795 XMLVALUE_In hid dividual_Demo 61_32000 graphics xml_index_nodes_20215822 PXML_Product id Model_Catalog 40_32000 Description xml_index_nodes_20215822 PXML_Product pk1 Model_Catalog 40_32000 Description xml_index_nodes_20215822 PXML_Product id Model_Instructi 40_32001 ons xml_index_nodes_20215822 PXML_Product pk1 Model_Instructi 40_32001 ons xml_index_nodes_21301066 PXML_Store_ id 29_32000 Demographics

Table Name xml_index_nodes_21301066 29_32000 xml_index_nodes_30957614 1_32000 xml_index_nodes_30957614 1_32000

Index Name

Column Name

Index Type CLUSTER ED CLUSTER ED CLUSTER ED

Is Is Unique Is Is Unique Is Primary Constraint Disabled Is Padded Hypotheti Key cal true true true false false false false false false false false false false false false false false false

PXML_Store_ pk1 Demographics PXML_Contact id _AddContact PXML_Contact pk1 _AddContact

Triggers
Name dEmployee iWorkOrder uWorkOrder iPurchaseOrderDetail uPurchaseOrderDetail uPurchaseOrderHeader dVendor iduSalesOrderDetail uSalesOrderHeader iStore iuIndividual HumanResources Production Production Purchasing Purchasing Purchasing Purchasing Sales Sales Sales Sales Trigger Schema

dEmployee
Trigger Body

Text CREATE TRIGGER [HumanResources].[dEmployee] ON [HumanResources].[Employee] INSTEAD OF DELETE NOT FOR REPLICATION AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN RAISERROR (N'Employees cannot be deleted. They can only be marked as not current.', -- Message 10, -- Severity. 1); -- State. -- Rollback any active or uncommittable transactions IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END END; END;

Dependent Objects ---None---

iWorkOrder
Trigger Body Text CREATE TRIGGER [Production].[iWorkOrder] ON [Production].[WorkOrder] AFTER INSERT AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY INSERT INTO [Production].[TransactionHistory]( [ProductID] ,[ReferenceOrderID]

Text ,[TransactionType] ,[TransactionDate] ,[Quantity] ,[ActualCost]) SELECT inserted.[ProductID] ,inserted.[WorkOrderID] ,'W' ,GETDATE() ,inserted.[OrderQty] ,0 FROM inserted; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH;

Text END;

Dependent Objects Dependent Obj uspLogError uspPrintError TransactionHistory SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE Dependent Obj Type

uWorkOrder
Trigger Body Text CREATE TRIGGER [Production].[uWorkOrder] ON [Production].[WorkOrder] AFTER UPDATE AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON;

Text BEGIN TRY IF UPDATE([ProductID]) OR UPDATE([OrderQty]) BEGIN INSERT INTO [Production].[TransactionHistory]( [ProductID] ,[ReferenceOrderID] ,[TransactionType] ,[TransactionDate] ,[Quantity]) SELECT inserted.[ProductID] ,inserted.[WorkOrderID] ,'W' ,GETDATE() ,inserted.[OrderQty] FROM inserted; END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0

Text BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError TransactionHistory WorkOrder SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE USER_TABLE Dependent Obj Type

iPurchaseOrderDetail
Trigger Body Text CREATE TRIGGER [Purchasing].[iPurchaseOrderDetail] ON [Purchasing].[PurchaseOrderDetail] AFTER INSERT AS BEGIN

Text DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY INSERT INTO [Production].[TransactionHistory] ([ProductID] ,[ReferenceOrderID] ,[ReferenceOrderLineID] ,[TransactionType] ,[TransactionDate] ,[Quantity] ,[ActualCost]) SELECT inserted.[ProductID] ,inserted.[PurchaseOrderID] ,inserted.[PurchaseOrderDetailID] ,'P' ,GETDATE() ,inserted.[OrderQty] ,inserted.[UnitPrice]

Text FROM inserted INNER JOIN [Purchasing].[PurchaseOrderHeader] ON inserted.[PurchaseOrderID] = [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID]; -- Update SubTotal in PurchaseOrderHeader record. Note that this causes the -- PurchaseOrderHeader trigger to fire which will update the RevisionNumber. UPDATE [Purchasing].[PurchaseOrderHeader] SET [Purchasing].[PurchaseOrderHeader].[SubTotal] = (SELECT SUM([Purchasing].[PurchaseOrderDetail].[LineTotal]) FROM [Purchasing].[PurchaseOrderDetail] WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] = [Purchasing].[PurchaseOrderDetail].[PurchaseOrderID]) WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] IN (SELECT inserted.[PurchaseOrderID] FROM inserted); END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH;

Text END;

Dependent Objects Dependent Obj uspLogError uspPrintError PurchaseOrderDetail PurchaseOrderHeader TransactionHistory SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

uPurchaseOrderDetail
Trigger Body Text CREATE TRIGGER [Purchasing].[uPurchaseOrderDetail] ON [Purchasing].[PurchaseOrderDetail] AFTER UPDATE AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN;

Text SET NOCOUNT ON; BEGIN TRY IF UPDATE([ProductID]) OR UPDATE([OrderQty]) OR UPDATE([UnitPrice]) -- Insert record into TransactionHistory BEGIN INSERT INTO [Production].[TransactionHistory] ([ProductID] ,[ReferenceOrderID] ,[ReferenceOrderLineID] ,[TransactionType] ,[TransactionDate] ,[Quantity] ,[ActualCost]) SELECT inserted.[ProductID] ,inserted.[PurchaseOrderID] ,inserted.[PurchaseOrderDetailID] ,'P' ,GETDATE() ,inserted.[OrderQty] ,inserted.[UnitPrice] FROM inserted INNER JOIN [Purchasing].[PurchaseOrderDetail]

Text ON inserted.[PurchaseOrderID] = [Purchasing].[PurchaseOrderDetail].[PurchaseOrderID]; -- Update SubTotal in PurchaseOrderHeader record. Note that this causes the -- PurchaseOrderHeader trigger to fire which will update the RevisionNumber. UPDATE [Purchasing].[PurchaseOrderHeader] SET [Purchasing].[PurchaseOrderHeader].[SubTotal] = (SELECT SUM([Purchasing].[PurchaseOrderDetail].[LineTotal]) FROM [Purchasing].[PurchaseOrderDetail] WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] = [Purchasing].[PurchaseOrderDetail].[PurchaseOrderID]) WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] IN (SELECT inserted.[PurchaseOrderID] FROM inserted); UPDATE [Purchasing].[PurchaseOrderDetail] SET [Purchasing].[PurchaseOrderDetail].[ModifiedDate] = GETDATE() FROM inserted WHERE inserted.[PurchaseOrderID] = [Purchasing].[PurchaseOrderDetail].[PurchaseOrderID] AND inserted.[PurchaseOrderDetailID] = [Purchasing].[PurchaseOrderDetail].[PurchaseOrderDetailID]; END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog

Text IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError PurchaseOrderDetail PurchaseOrderHeader TransactionHistory SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

uPurchaseOrderHeader
Trigger Body Text CREATE TRIGGER [Purchasing].[uPurchaseOrderHeader] ON [Purchasing].[PurchaseOrderHeader]

Text AFTER UPDATE AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY -- Update RevisionNumber for modification of any field EXCEPT the Status. IF NOT UPDATE([Status]) BEGIN UPDATE [Purchasing].[PurchaseOrderHeader] SET [Purchasing].[PurchaseOrderHeader].[RevisionNumber] = [Purchasing].[PurchaseOrderHeader].[RevisionNumber] + 1 WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] IN (SELECT inserted.[PurchaseOrderID] FROM inserted); END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before

Text -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError PurchaseOrderHeader SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE Dependent Obj Type

dVendor
Trigger Body Text CREATE TRIGGER [Purchasing].[dVendor] ON [Purchasing].[Vendor] INSTEAD OF DELETE NOT FOR REPLICATION AS

Text BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY DECLARE @DeleteCount int; SELECT @DeleteCount = COUNT(*) FROM deleted; IF @DeleteCount > 0 BEGIN RAISERROR (N'Vendors cannot be deleted. They can only be marked as not active.', -- Message 10, -- Severity. 1); -- State. -- Rollback any active or uncommittable transactions IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END

Text END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE Dependent Obj Type

iduSalesOrderDetail
Trigger Body Text CREATE TRIGGER [Sales].[iduSalesOrderDetail] ON [Sales].[SalesOrderDetail] AFTER INSERT, DELETE, UPDATE AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY -- If inserting or updating these columns IF UPDATE([ProductID]) OR UPDATE([OrderQty]) OR UPDATE([UnitPrice]) OR UPDATE([UnitPriceDiscount]) -- Insert record into TransactionHistory BEGIN INSERT INTO [Production].[TransactionHistory] ([ProductID] ,[ReferenceOrderID] ,[ReferenceOrderLineID] ,[TransactionType] ,[TransactionDate]

Text ,[Quantity] ,[ActualCost]) SELECT inserted.[ProductID] ,inserted.[SalesOrderID] ,inserted.[SalesOrderDetailID] ,'S' ,GETDATE() ,inserted.[OrderQty] ,inserted.[UnitPrice] FROM inserted INNER JOIN [Sales].[SalesOrderHeader] ON inserted.[SalesOrderID] = [Sales].[SalesOrderHeader].[SalesOrderID]; UPDATE [Sales].[Individual] SET [Demographics].modify('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; replace value of (/IndividualSurvey/TotalPurchaseYTD)[1] with data(/IndividualSurvey/TotalPurchaseYTD)[1] + sql:column ("inserted.LineTotal")') FROM inserted INNER JOIN [Sales].[SalesOrderHeader] ON inserted.[SalesOrderID] = [Sales].[SalesOrderHeader].[SalesOrderID] WHERE [Sales].[SalesOrderHeader].[CustomerID] = [Sales].[Individual].[CustomerID]; END;

Text -- Update SubTotal in SalesOrderHeader record. Note that this causes the -- SalesOrderHeader trigger to fire which will update the RevisionNumber. UPDATE [Sales].[SalesOrderHeader] SET [Sales].[SalesOrderHeader].[SubTotal] = (SELECT SUM([Sales].[SalesOrderDetail].[LineTotal]) FROM [Sales].[SalesOrderDetail] WHERE [Sales].[SalesOrderHeader].[SalesOrderID] = [Sales].[SalesOrderDetail].[SalesOrderID]) WHERE [Sales].[SalesOrderHeader].[SalesOrderID] IN (SELECT inserted.[SalesOrderID] FROM inserted); UPDATE [Sales].[Individual] SET [Demographics].modify('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; replace value of (/IndividualSurvey/TotalPurchaseYTD)[1] with data(/IndividualSurvey/TotalPurchaseYTD)[1] - sql:column("deleted.LineTotal")') FROM deleted INNER JOIN [Sales].[SalesOrderHeader] ON deleted.[SalesOrderID] = [Sales].[SalesOrderHeader].[SalesOrderID] WHERE [Sales].[SalesOrderHeader].[CustomerID] = [Sales].[Individual].[CustomerID]; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0

Text BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError Individual SalesOrderDetail SalesOrderHeader TransactionHistory SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE USER_TABLE USER_TABLE USER_TABLE Dependent Obj Type

uSalesOrderHeader
Trigger Body Text CREATE TRIGGER [Sales].[uSalesOrderHeader] ON [Sales].[SalesOrderHeader]

Text AFTER UPDATE NOT FOR REPLICATION AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY -- Update RevisionNumber for modification of any field EXCEPT the Status. IF NOT UPDATE([Status]) BEGIN UPDATE [Sales].[SalesOrderHeader] SET [Sales].[SalesOrderHeader].[RevisionNumber] = [Sales].[SalesOrderHeader].[RevisionNumber] + 1 WHERE [Sales].[SalesOrderHeader].[SalesOrderID] IN (SELECT inserted.[SalesOrderID] FROM inserted); END; -- Update the SalesPerson SalesYTD when SubTotal is updated IF UPDATE([SubTotal]) BEGIN DECLARE @StartDate datetime,

Text @EndDate datetime SET @StartDate = [dbo].[ufnGetAccountingStartDate](); SET @EndDate = [dbo].[ufnGetAccountingEndDate](); UPDATE [Sales].[SalesPerson] SET [Sales].[SalesPerson].[SalesYTD] = (SELECT SUM([Sales].[SalesOrderHeader].[SubTotal]) FROM [Sales].[SalesOrderHeader] WHERE [Sales].[SalesPerson].[SalesPersonID] = [Sales].[SalesOrderHeader].[SalesPersonID] AND ([Sales].[SalesOrderHeader].[Status] = 5) -- Shipped AND [Sales].[SalesOrderHeader].[OrderDate] BETWEEN @StartDate AND @EndDate) WHERE [Sales].[SalesPerson].[SalesPersonID] IN (SELECT DISTINCT inserted.[SalesPersonID] FROM inserted WHERE inserted.[OrderDate] BETWEEN @StartDate AND @EndDate); -- Update the SalesTerritory SalesYTD when SubTotal is updated UPDATE [Sales].[SalesTerritory] SET [Sales].[SalesTerritory].[SalesYTD] = (SELECT SUM([Sales].[SalesOrderHeader].[SubTotal]) FROM [Sales].[SalesOrderHeader] WHERE [Sales].[SalesTerritory].[TerritoryID] = [Sales].[SalesOrderHeader].[TerritoryID] AND ([Sales].[SalesOrderHeader].[Status] = 5) -- Shipped AND [Sales].[SalesOrderHeader].[OrderDate] BETWEEN @StartDate AND @EndDate) WHERE [Sales].[SalesTerritory].[TerritoryID]

Text IN (SELECT DISTINCT inserted.[TerritoryID] FROM inserted WHERE inserted.[OrderDate] BETWEEN @StartDate AND @EndDate); END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects Dependent Obj uspLogError uspPrintError SalesOrderHeader SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE Dependent Obj Type

Dependent Obj SalesPerson SalesTerritory USER_TABLE USER_TABLE

Dependent Obj Type

iStore
Trigger Body Text CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store] AFTER INSERT AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY -- Only allow the Customer to be a Store OR Individual IF EXISTS (SELECT * FROM inserted INNER JOIN [Sales].[Individual] ON inserted.[CustomerID] = [Sales].[Individual].[CustomerID]) BEGIN

Text -- Rollback any active or uncommittable transactions IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; -- Rollback any active or uncommittable transactions before -- inserting information in the ErrorLog IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END;

Dependent Objects

Dependent Obj uspLogError uspPrintError Individual SQL_STORED_PROCEDURE SQL_STORED_PROCEDURE USER_TABLE

Dependent Obj Type

iuIndividual
Trigger Body Text CREATE TRIGGER [Sales].[iuIndividual] ON [Sales].[Individual] AFTER INSERT, UPDATE NOT FOR REPLICATION AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; -- Only allow the Customer to be a Store OR Individual IF EXISTS (SELECT * FROM inserted INNER JOIN [Sales].[Store] ON inserted.[CustomerID] = [Sales].[Store].[CustomerID]) BEGIN

Text -- Rollback any active or uncommittable transactions IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END END; IF UPDATE([CustomerID]) OR UPDATE([Demographics]) BEGIN UPDATE [Sales].[Individual] SET [Sales].[Individual].[Demographics] = N'<IndividualSurvey xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"> <TotalPurchaseYTD>0.00</TotalPurchaseYTD> </IndividualSurvey>' FROM inserted WHERE [Sales].[Individual].[CustomerID] = inserted.[CustomerID] AND inserted.[Demographics] IS NULL; UPDATE [Sales].[Individual] SET [Demographics].modify(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventureworks/IndividualSurvey"; insert <TotalPurchaseYTD>0.00</TotalPurchaseYTD> as first into (/IndividualSurvey)[1]') FROM inserted WHERE [Sales].[Individual].[CustomerID] = inserted.[CustomerID]

Text AND inserted.[Demographics] IS NOT NULL AND inserted.[Demographics].exist(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; /IndividualSurvey/TotalPurchaseYTD') <> 1; END; END;

Dependent Objects Dependent Obj Individual Store USER_TABLE USER_TABLE Dependent Obj Type

Dashboards

Sign up to vote on this title
UsefulNot useful