I'm trying to query using a XPath expression. My Microsoft SQL Server 2008 RC2 knows the functions value() and query() but is missing the nodes() method.
Example:
SELECT Data.nodes('/root/ids/id') As id FROM myTable
Data is a XML column in the table myTable.
Is it required to install the nodes() method somehow?
nodes can return more than one row so you don't call it as though it returns a scalar
with myTable as
(
SELECT CAST('<root><ids><id>1</id><id>2</id></ids></root>' AS XML) AS Data
)
SELECT x.value('.', 'int')
FROM myTable
CROSS APPLY Data.nodes('/root/ids/id') x(x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With