Value
Description
Sample Source Patterns
SQL Server
CREATE TABLE xml_demo(object_col XML);
INSERT INTO xml_demo (object_col)
SELECT
'<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features>
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
</Root>';
INSERT INTO xml_demo (object_col)
SELECT
'<Root>
<ProductDescription ProductID="2" ProductName="Skate">
<Features>
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
</Root>';
SELECT
xml_demo.object_col.value('(/Root/ProductDescription/@ProductID)[1]', 'int' ) as ID,
xml_demo.object_col.value('(/Root/ProductDescription/@ProductName)[1]', 'varchar(max)' ) as ProductName,
xml_demo.object_col.value('(/Root/ProductDescription/Features/Warranty)[1]', 'varchar(max)' ) as Warranty
from xml_demo;
Snowflake SQL
Known Issues
Related EWIs
Last updated
Was this helpful?