title: adding encoding information to the result of FOR XML
body: <p>I have a Script, which returns a XML using FOR XML in SQL 2008. Is there any way to add the version and encoding information in the beginning of the output. Eventually, i am planning to save the output in a file.</p>
  
  <p>For example, right now my output looks like this </p>
  
  <pre><code>&lt;Agents&gt;
    &lt;Agent id="1"&gt;
      &lt;Name&gt;Mike&lt;/Name&gt;
      &lt;Location&gt;Sanfrancisco&lt;/Location&gt;
    &lt;/Agent&gt;
    &lt;Agent id="2"&gt;
      &lt;Name&gt;John&lt;/Name&gt;
      &lt;Location&gt;NY&lt;/Location&gt;
    &lt;/Agent&gt;
  &lt;/Agents&gt;
  </code></pre>
  
  <p>I would like to append the line <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code> in the beginning of the Xml output</p>
  
  <p>So i want the output something like </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Agents&gt;
   &lt;Agent id="1"&gt;
     &lt;Name&gt;Mike&lt;/Name&gt;
     &lt;Location&gt;Sanfrancisco&lt;/Location&gt;
   &lt;/Agent&gt;
  &lt;Agent id="2"&gt;
    &lt;Name&gt;John&lt;/Name&gt;
    &lt;Location&gt;NY&lt;/Location&gt;
  &lt;/Agent&gt;
  </code></pre>
  
  <p></p>