Reputation: 29159
I have the following xml
declare @xml xml = '<Values><a>AAA</a><b>BBB</b></Values>';
select @xml.query('for $k in /Values return concat(",@", "=''", $k, "''")')
It returns
,@='AAABBB'
However I expect
,@a='AAA',@b='BBB'
How to write the xquery?
Upvotes: 0
Views: 678
Reputation: 29159
I figured it out myself.
declare @xml xml = '<Values><a>AAA</a><b>BBB</b></Values>';
select @xml.query('for $k in /Values/*
return concat(",@", fn:local-name($k), "=''", $k, "''")')
Upvotes: 2