Thursday, 5 September 2013

long path xquery in MSSQL

long path xquery in MSSQL

Below is my code in SSMS. and is working fine. but problem is my
@p1='variable1/variable2', and i am not able to get the result.
Thank you.
DECLARE @SSRXML xml = '<root>
<variable1>
<variable2>
<variable3>
<name>Alvin</name>
<country>Singapore</country>
</variable3>
</variable2>
</variable1>
</root>'
DECLARE @p1 VARCHAR(MAX) = 'variable1';
SELECT @SSRXML.query('//root/*[local-name()=sql:variable("@p1")]' )

1 comment: