您现在的位置: 万盛学电脑网 >> 程序编程 >> 数据库 >> mssql数据库 >> 正文

在SQL中生成XML文本

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 在SQL中自定义XML的根节点和子节点

select * from table FOR XML PATH('child'),ROOT('parent')

多表查询一个主表一个子表的话

select *,

(select * from subTable where subTable.id=master.id

FOR XML PATH('child'),ROOT('parent'),TYPE

)

from master

FOR XML PATH('child'),ROOT('parent')