This user-defined function (UDF) generates a query from an XML reading.
OPENXML_UDF(XML VARCHAR, PATH VARCHAR)
The path of the node to extract.
Returns a table with the data generated by the XML reading.
SELECT * FROM TABLE(OPENXML_UDF('<iceCreamOrders>
<order>
<customer customerID="CUST001" contactName="Test ABC">
<iceCreamOrder orderID="ORD001" employeeID="101" orderDate="2023-05-15T14:30:00">
<iceCreamDetail productID="001" quantity="2"/>
<iceCreamDetail productID="003" quantity="1"/>
</iceCreamOrder>
</customer>
</order>
<order>
<customer customerID="CUST002" contactName="Test XYZ">
<iceCreamOrder orderID="ORD002" employeeID="102" orderDate="2023-06-20T12:45:00">
<iceCreamDetail productID="005" quantity="3"/>
<iceCreamDetail productID="007" quantity="2"/>
</iceCreamOrder>
</customer>
</order>
</iceCreamOrders>
', 'iceCreamOrders:order'));