I have a table that contains a column that is XML data type. I am looking to put a view over the entire table including the XML data type column. The view will expand contents of the XML data type column. I am having a problem being able to traverse the entire XML document and pick up values from particular XML nodes.
I am using this SQL query and it's only picking up the first instance of value for the FuelPathwayCode XML node. I am looking to traverse an entire XML document and query ALL values of the /FuelPathwayCode XML node in one result set?
SELECT
UploadFileID, Year, Quarter,
FileContent.value('(LCFS-Report/Fuel/FuelPathwayCode)[1]', 'varchar(100)') as FuelPathwayCode
FROM LC_UploadXM
I am looking for a result set like this:
UploadFileID Year Quarter FuelPathWayCode PhysicalPathwayCode
8 2010 4 CARBOB001 PP001
8 2010 4 CARBOB002-HIGH PP001
Table Columns:
UploadFileID,
Year,
Quarter,
CompanyID,
FileType,
FileContent,
FileName,
Description,
Success,
AddBy,
AddDttm