EDUDOTNET

Friday, September 6, 2013

How to create sql query result to xml file

Create Sql Query Result To XML Format

Sql Query: Getting all users data from sql server in xml file format...

See below Query:

SELECT *
FROM dbo.Users
FOR XML PATH('User'), ROOT ('Users')

Results: (XML Format):

<Users>
  <User>
    <UserID>8eaf6426-63e4-49c7-939e-1b0f43586084</UserID>
    <RoleID>4</RoleID>
    <FirstName>Thomas</FirstName>
    <LastName>Dalm</LastName>
    <Password>iJletJwlcqUrAIC98rggvA==</Password>
    <EmailID>thomas.edu@gmail.com</EmailID>
    <CreatedDate>2013-05-29T06:39:48.217</CreatedDate>
    <IsActive>1</IsActive>
    <CompanyName>EDUDOTNET</CompanyName>
    <LastPasswordChangedDate>2013-07-1T08:31:14.150</LastPasswordChangedDate
  </User>
  <User>
    <UserID>1e922995-d0f9-e211-b767-3c4a92dbc8db</UserID>
    <RoleID>1</RoleID>
    <FirstName>Khumesh</FirstName>
    <LastName>Kumawat</LastName>
    <Password>iJletJwlcqUrAIC98rggvA==</Password>
    <EmailID>khumesh.edu@gmail.com</EmailID>
    <CreatedDate>2013-05-29T06:39:48.217</CreatedDate>
    <IsActive>1</IsActive>
    <CompanyName>EDUDOTNET</CompanyName>
    <LastPasswordChangedDate>2013-07-1T08:31:14.150</LastPasswordChangedDate>
  </User

</Users>

0 comments:

Post a Comment