sql server数据表转换成xml

it2022-05-09  64

运用 for xml 但是SQL2000对此支持不好,用SQL2005比较好 例如下表 sno sname ssex 08020001 李勇 男 08020002 刘晨 女 08020003 王敏 女 08020004 张立 男 SQL语句: select rtrim(sno) as "@no",rtrim(sname) as "@name",rtrim(ssex) as "@sex" from student for xml path('student'),type,root('allStudents') 结果为: <allStudents> <student no="08020001" name="李勇" sex="男" /> <student no="08020002" name="刘晨" sex="女" /> <student no="08020003" name="王敏" sex="女" /> <student no="08020004" name="张立" sex="男" /> </allStudents>

 

转载于:https://www.cnblogs.com/goto/archive/2012/10/09/2716146.html

相关资源:SQL 数据表转化为XML 文件

最新回复(0)