title: Can you export SQL Server 2012 data into an XML file
body: <p>Below is a very small example of the SQL and XML but no idea how to export this into say C:\Users\Simon.Evans\Documents\Test.xml. To be fair I have very little to zero knowledge of XML so walking in the dark. Ultimately I am trying to find a way to export for SQL tables into an XML file.</p>
  
  <pre><code>SELECT 
      patient.OID AS '@ID',
      patient.FORENAME, patient.SURNAME,
      patient.TITLECODE,
      patient.BIRTHDTTM
  FROM 
      HealthBI.dbo.LZO_PATIENT patient
  WHERE patient.OID = '3400000000'
  FOR XML PATH('Patient'), ROOT('Patient')
  </code></pre>
  
  <p>and the XML output of the sql is:</p>
  
  <pre><code>&lt;Patient&gt;
    &lt;Patient ID="3400000000"&gt;
      &lt;FORENAME&gt;IDA&lt;/FORENAME&gt;
      &lt;SURNAME&gt;CARR&lt;/SURNAME&gt;
      &lt;TITLECODE&gt;CC_MRS&lt;/TITLECODE&gt;
      &lt;BIRTHDTTM&gt;1929-10-25T00:00:00&lt;/BIRTHDTTM&gt;
    &lt;/Patient&gt;
  &lt;/Patient&gt;
  </code></pre>