How to Convert SQL Data to XML

I have a sample Employee table. We will fire a select query to check data in the table.

  1. select * from employee  
The following is the data in the table.



Now we will see how to convert this data in XML.

Write down the below query in the Query Analyser.
  1. select * from employee for xml raw  
Let us check the output now.



Click on the XMl generated. And in a new window we get the following XML resultset.