如何在存储过程的取得FOR XML 生成的XML字符串??
我在存储过程中利用FOR XML 从表中取得了数据,如
select * from orderbill inner join orderItem on orderbill.pkid = orderitem.billid where orderbill.pkid =1 for xml auto
结果如下:
XML_F52E2B61-18A1-11d1-B105-00805F49916B
--------------------------------------------------------------------
<orderbill pkid="1" custom="张三" data="2000-08-01T00:00:00" remark="东西">
<orderItem pkid="1" product="电视" pcount="2" billid="1"/>
<orderItem pkid="2" product="冰箱" pcount="3" billid="1"/>
<orderItem pkid="3" product="椅子" pcount="34" billid="1"/>
</orderbill>
(所影响的行数为 3 行)
但是我想把这个结果存入一个变量@str nvarchar(4000)中去,似乎没找到可用的语句。