Create XML in SQL Server

Hello friends, We have already explain regarding IIF() in SQL Server,Right Join in SQL Server,left join in SQLSelf Join in SQL Server , RANK(),  DENSE_RANK()ROW_NUMBER() and  Aggregate functions in sql server. Today I am going to explain regarding Create XML in SQL Server, however this is my first step toward writing post.  I will also explain “How to create XML by using various methods in SQL Server” step by step.

XML is one of the Datatype of SQL Server which introduced in SQL Server 2005 and it is implemented and used in SQL Server 2008.

FOR XML Clause :

SQL Server lets you retrieve data as XML by supporting the FOR XML clause, which can be included as part of your query. You can use the FOR XML clause in the main (outer) query as well as in sub-queries. FOR XML clause supports numerous options that let you define the format of the XML data.

There are four modes supported by FOR XML clause:

  1. RAW

  2. AUTO

  3. EXPLICIT

  4. PATH

Leave a Reply