SQL SERVER中如何将xml输出成表?
有如下xml:
DECLARE @XXX varchar(max)
set @xxx = '
<v>
<aa>12345</aa>
<bb>23456</bb>
</v>
<v>
<aa>54321</aa>
<bb>65432</bb>
</v>'
输出为一个表,列为aa,bb
现在我这么写的,但我只能取到aa列,想知道如果同时取到?
SELECT F.p.value('.', 'varchar(5)') as cid ROM @XXX .nodes('/v') AS F(p)
------解决方案--------------------
http://www.docin.com/p-59480178.html
http://www.cnblogs.com/jintan/archive/2010/08/23/1806362.html
------解决方案--------------------
SQL code
DECLARE @XXX xml
set @xxx = '
<v>
<aa>12345</aa>
<bb>23456</bb>
</v>
<v>
<aa>54321</aa>
<bb>65432</bb>
</v>'
SELECT F.p.value('aa[1]', 'varchar(5)') as aa,F.p.value('bb[1]', 'varchar(5)') AS bb FROM @XXX .nodes('/v') AS F(p)