我需要类似的东西
select * from tb_listings for xml auto
但我需要每一行都是分开的,而不是一个大的 xml 文档。
我尝试过类似以下的方法:
select id, (select * from tb_listings a where a.id=id for xml auto) as xmldata from tb_listings
预期输出如下:
id xmldata
------------------------------------------------------------
1 <listing><name>ABC</name><xyz>123</xyz></listing>
但它似乎并没有做我想要的,而且它也需要很长时间才能运行。
任何想法,将不胜感激。:)
编辑:想通了:
select id, (select top 1 * from tb_listings a where a.id=b.id for xml auto) from tb_listings b
关闭。