AdventureWorks
Sales.vIndividualDemographics View
Description
Displays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.
Properties
Creation Date08/01/2010 08:41
Is Schema Bound
Encrypted
Ansi Nulls
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
 CustomerID int4   
 TotalPurchaseYTD money8  
 DateFirstPurchase datetime4  
 BirthDate datetime4  
 MaritalStatus nvarchar1  
 YearlyIncome nvarchar30  
 Gender nvarchar1  
 TotalChildren int4  
 NumberChildrenAtHome int4  
 Education nvarchar30  
 Occupation nvarchar30  
 HomeOwnerFlag bit1  
 NumberCarsOwned int4  
Objects that Sales.vIndividualDemographics depends on
 Database ObjectObject TypeDescriptionDep Level
Person.Contact tablePerson.ContactTableNames of each employee, customer contact, and vendor contact.2
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Individual and Store tables.2
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.4
dbo.ErrorLog tabledbo.ErrorLogTableAudit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct.4
dbo.Flag datatypedbo.FlagUser Defined Data Type 5
Sales.Individual tableSales.IndividualTableDemographic data about customers that purchase Adventure Works products online.1
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 3
dbo.Phone datatypedbo.PhoneUser Defined Data Type 3
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.3
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.3
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.2
dbo.ufnLeadingZeros functiondbo.ufnLeadingZerosUser Defined FunctionScalar function used by the Sales.Customer table to help set the account number.3
dbo.uspLogError proceduredbo.uspLogErrorStored ProcedureLogs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information.3
dbo.uspPrintError proceduredbo.uspPrintErrorStored ProcedurePrints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information.3
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/adventure-works/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/adventure-works/IndividualSurvey"; 
MaritalStatus[1]', 'nvarchar(1)') AS [MaritalStatus] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
YearlyIncome[1]', 'nvarchar(30)') AS [YearlyIncome] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
Gender[1]', 'nvarchar(1)') AS [Gender] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
TotalChildren[1]', 'integer') AS [TotalChildren] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
NumberChildrenAtHome[1]', 'integer') AS [NumberChildrenAtHome] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
Education[1]', 'nvarchar(30)') AS [Education] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
Occupation[1]', 'nvarchar(30)') AS [Occupation] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
HomeOwnerFlag[1]', 'bit') AS [HomeOwnerFlag] 
,[IndividualSurvey].[ref].[value](N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
NumberCarsOwned[1]', 'integer') AS [NumberCarsOwned] 
FROM [Sales].[Individual] i 
CROSS APPLY i.[Demographics].nodes(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"; 
/IndividualSurvey') AS [IndividualSurvey](ref) 
WHERE [Demographics] IS NOT NULL;
See Also

Related Objects

Sales Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.