SQL FOR XML 帮助
问题很简单,但我是在 SQL 2005 中形成 XML 的新手,但是用于形成下面从类似这样的表中看到的 XML 的最佳 FOR XML SQL 语句是什么?
Column1 Column2
------------------------
Baseball Football
Cricket Polo
Swim Beach
所需的 XML 输出:
<Category Name="Baseball">
<Subcategory>Football</Subcategory>
</Category>
<Category Name="Cricket">
<SubCategory>Polo</Subcategory>
</Category>
<Category Name="Swim">
<SubCategory>Beach</Subcategory>
</Category>
Prob an easy question, but I am new to forming XML in SQL 2005, but What would be the best FOR XML SQL statement to use to form the XML seen below from a table that looks like this?
Column1 Column2
------------------------
Baseball Football
Cricket Polo
Swim Beach
Desired XML output:
<Category Name="Baseball">
<Subcategory>Football</Subcategory>
</Category>
<Category Name="Cricket">
<SubCategory>Polo</Subcategory>
</Category>
<Category Name="Swim">
<SubCategory>Beach</Subcategory>
</Category>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未经测试:
基于此处找到的示例。
Untested:
Based on examples found here.