How to convert records in a table to xml format using T-SQL?

前端 未结 3 1912
渐次进展
渐次进展 2020-12-14 01:19

I\'ve got a simple table and want to store its content into a xml on the harddrive. There should be one root element for the whole table, one element per table row and one c

3条回答
  •  独厮守ぢ
    2020-12-14 02:19

    Use the FOR XML in your query.

    E.g: select * from table1 FOR XML AUTO

    see this --> http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1265579,00.html

    Alternatively, you can create your own XML in your t-sql code through cursors or in your application code, the longer way of doing it.

提交回复
热议问题