Sales.vPersonDemographics
Documentation | AdventureWorks |
Schema | Sales |
Name | vPersonDemographics |
Module | Sales |
Displays the content from each element in the xml column Demographics for each customer in the Person.Person table.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | BusinessEntityID | int | ||||||
2 | TotalPurchaseYTD | money | ||||||
3 | DateFirstPurchase | datetime | ||||||
4 | BirthDate | datetime | ||||||
5 | MaritalStatus | nvarchar(1) | ||||||
6 | YearlyIncome | nvarchar(30) | ||||||
7 | Gender | nvarchar(1) | ||||||
8 | TotalChildren | int | ||||||
9 | NumberChildrenAtHome | int | ||||||
10 | Education | nvarchar(30) | ||||||
11 | Occupation | nvarchar(30) | ||||||
12 | HomeOwnerFlag | bit | ||||||
13 | NumberCarsOwned | int |
Uses
Name |
---|
Sales.vPersonDemographics
|
IndividualSurvey.ref.value
|
Script
CREATE VIEW [Sales].[vPersonDemographics] AS SELECT p.[BusinessEntityID] ,[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 [Person].[Person] p CROSS APPLY p.[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; |
Exported: 2019-02-04 23:13, Last imported: 2018-03-07 11:56