title: What is :XML ON in T-SQL query to export data into XML using SQLCMD?
body: <p>On this <a href="http://www.excel-sql-server.com/sql-server-export-to-excel-using-bcp-sqlcmd-xml.htm#SQL%20Server%20Data%20Export%20to%20XML%20using%20SQLCMD" rel="nofollow">blog post about exporting data to XML</a> with TSQL using BCP or SQLCMD I came across this line of code:</p>
  
  <pre><code>:XML ON
  
  SELECT
      *
  FROM
      dbo02.ExcelTest
  FOR XML AUTO, ELEMENTS, ROOT('doc')
  </code></pre>
  
  <p>I tried using it in the sql query and then triggering via sqlcmd in a batch file, it did return a correct xml file. Without the <code>:XML ON</code> it returns strange values as described on the webpage. </p>
  
  <p>Strangely enough, SSMS (2008) shows incorrect syntax when parsing or executing the query. </p>
  
  <p>What does <code>:XML ON</code> do and how to use it? And why doesn't SSMS recognize the line of code? </p>