Monday, April 27, 2015

Create xml file from sql server table


Following code will create xml file from sql server table.

SQL Server Table








XML Output
<myroot>
    <blogs>>/blogs>
          <blogid>2601</blogid>
          <title>Program to illustrate operator overloading from string</title>
          <contentvalue>blah blah blah</contentvalue>
          <creationdate>2013-02-18 13:57:00</creationdate>
   
     ....
     ....
     ....
     ....
     ....
</myroot>


Script to convert sql server table to xml file

declare @XmlOutput xml

set @XmlOutput =
(select BlogId, Title, ContentValue, CreationDate from Blogs
FOR XML AUTO, ROOT('MyRoot'), ELEMENTS)

select @XmlOutput

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape