Example 01
-------------------------------------
TreadDepths - Column contents:
<tD lF="1605" rF="1605" lR1="1608" rR1="1608" sp="1606" />
PartID = 0,
TyreDepthLeftFront = r.value('@lF', 'int'),
TyreDepthRightFront = r.value('@rF', 'int')
FROM inspections i
CROSS apply i.treaddepths.nodes('/tD') AS Res(r)
Example 02
-------------------------------------
<ArrayOfCustomers xmlns:xsd="https://www.w3.org/2001/XMLSchema"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">
<Customer>
<ItemId>1</ItemId>
<Value>Mr Smith</Value>
</Customer>
<Customer>
<ItemId>2</ItemId>
<Value>Mr Bloggs</Value>
</Customer>
</ArrayOfCustomers>
SELECT cust.value('(ItemId)[1]', 'int') AS 'ItemID',
cust.value('(Value)[1]', 'Varchar(50)') AS 'Customer Name'
FROM dbo.sales.customerlist.nodes('/ArrayOfCustomers/Customer') AS AOC(cust)
Example 03
-------------------------------------
<vFs>
<vF fId="1896" ds="Power Rear Windows" />
<vF fId="1814" ds="Central Locking" />
<vF fId="1837" ds="Electric Mirrors" />
<vF fId="2023" ds="Steering Wheel Stereo Controls" />
<vF fId="1855" ds="Fog Lamps" />
<vF fId="1765" ds="Dual Airbags" />
<vF fId="1769" ds="ABS (Antilock Brakes)" />
<vF fId="1773" ds="Air Conditioning" />
<vF fId="17609" ds="14&quot; Steel Wheels" />
<vF fId="1890" ds="Park Distance Control" />
<vF fId="1970" ds="Radio CD Player" />
<vF fId="1889" ds="Power Steering" />
<vF fId="1892" ds="Power Front Windows" />
</vFs>
SELECT TOP 10 InspectionGUID = i.inspectionguid,
PartID = 0,
vehiclefeatures,
Features = f.value('@ds', 'varchar(255)')
FROM inspections i
CROSS apply i.vehiclefeatures.nodes('/vFs/vF') AS Feature(f)