title: INSERT XML into SQL Server 2008 database
body: <p>Hello I'm trying to insert some XML data into a table on SQL Server 2008.  However I keep getting thrown this error;</p>
  
  <blockquote>
    <p>XML parsing: line 1, character 39, unable to switch the encoding</p>
  </blockquote>
  
  <p>The database column filemeta uses the XML datatype, and I've switch the encoding to UTF-16 which I believe is necessary for adding XML data.</p>
  
  <pre><code>INSERT INTO testfiles
    (filename, filemeta) 
  VALUES 
    ('test.mp3', '&lt;?xml version="1.0" encoding="utf-16" standalone="yes"?&gt;&lt;!--This is a test XML file--&gt;&lt;filemeta filetype="Audio"&gt;&lt;Comments /&gt;&lt;AlbumTitle /&gt;&lt;TrackNumber /&gt;&lt;ArtistName /&gt;&lt;Year /&gt;&lt;Genre /&gt;&lt;TrackTitle /&gt;&lt;/filemeta&gt;');
  </code></pre>
  
  <p>Help, I'm stuck.</p>
  
  <p>NB: I created the XML with XMLTextWriter.</p>