I am try to implement the following code.
declare @para varchar(10) = 'b';
declare @x xml = '
<x>
<a>1111</a>
<b>2222</b>
<c>3333</c>
</x>';
select @x.query('/x/sql:variable("@para")');
The above code should get the node of <b>2222</b>
. However, it get the following error
Msg 9335, Level 16, State 1, Line 8 XQuery [query()]: The XQuery syntax '/function()' is not supported.
declare @para varchar(10) = 'b';
declare @x xml = '
<x>
<a>1111</a>
<b>2222</b>
<c>3333</c>
</x>';
select @x.query('/x/*[local-name()=sql:variable("@para")]');
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