title: Generating XML file from SQL Server 2008
body: <p>I am working on an application where I need to get the SQL response as XML into an XML file (and to store it in some physical location, say <em>c:\xyz.xml</em>).</p>
  
  <p>I am able to generate the XML content using the provisions available in SQL Server as shown below. </p>
  
  <pre><code> SELECT * FROM @Table FOR XML AUTO, ELEMENTS
  </code></pre>
  
  <p>where: <code>@Table</code> is a table variable. </p>
  
  <p>I want to know how I can store the query output to an XML file from SQL Server itself.</p>