title: SQL appending <?xml version="1.0" encoding="UTF-8"?> to Query output
body: <p>So i'm having a bit of trouble to figure out how i could make this work
  so that i can append the xml encoding 
  to my query.</p>
  
  <p>this is what i hacked together so far:</p>
  
  <pre><code>DECLARE @FileName VARCHAR(50)
  DECLARE @SQLCmd   VARCHAR(8000)
  
  SELECT  @FileName = 'C:\SampleXMLOutput.xml'
  
  -- in this command, we are making sure there is only one ROOT node
  
  
  SELECT @SQLCmd = + 'bcp ' + 
                           '"SELECT Id, Initials, firstname, lastname, email ' +
                           ' FROM Employees.dbo.IDCards ' +
                           ' FOR XML PATH(''Employee''), ELEMENTS,  ROOT(''Employees''), TYPE "' +
                           ' queryout '  +
                     @FileName +
                     ' -w -T -S' + @@SERVERNAME
  
  
  
  -- display command, for visual  check
  SELECT @SQLCmd AS 'Command to execute'
  
  -- create the XML file
  EXECUTE master..xp_cmdshell @SQLCmd
  </code></pre>
  
  <p>Also i need to get some data from another table within the same query output.</p>
  
  <p>Any help appreciated</p>