Views [Production].[vProductModelInstructions]
Displays the content from each element in the xml column Instructions for each product in the Production.ProductModel table that has manufacturing instructions.
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
ANSI Nulls OnTrue
Quoted Identifier OnTrue
Created13:14:55 14 marca 2012
Last Modified13:14:55 14 marca 2012
NameData TypeMax Length (Bytes)Identity
ProductModelIDint40 - 0
Name[dbo].[Name]100
Instructionsnvarchar(max)max
LocationIDint4
SetupHoursdecimal(9,4)5
MachineHoursdecimal(9,4)5
LaborHoursdecimal(9,4)5
LotSizeint4
Stepnvarchar(1024)2048
rowguiduniqueidentifier16
ModifiedDatedatetime8

CREATE VIEW [Production].[vProductModelInstructions]
AS
SELECT
   [ProductModelID]
   ,[Name]
   ,[Instructions].value(N'declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/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/adventure-works/ProductModelManuInstructions";
   /root/Location'
) MfgInstructions(ref)
CROSS APPLY [MfgInstructions].ref.nodes('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions";
   step'
) Steps(ref);
GO
EXEC sp_addextendedproperty N'MS_Description', N'Displays the content from each element in the xml column Instructions for each product in the Production.ProductModel table that has manufacturing instructions.', 'SCHEMA', N'Production', 'VIEW', N'vProductModelInstructions', NULL, NULL
GO