Translate

Friday 10 October 2014

How to make sql query result to xml file

Method 1:

SELECT *
FROM dbo.YourStudentTable
FOR XML PATH('Student'), ROOT ('Students')

Method 2:

DECLARE @x xml
SET @x=( SELECT *
FROM dbo.YourStudentTable  FOR XML RAW, TYPE,ROOT('myRoot'))
SELECT @x

Method 3:

SELECT * from  dbo.YourStudentTable
FOR XML RAW ('Employee'), ROOT ('Employees'), ELEMENTS XSINIL;