title: Inserting XML into SQL Server 2008
body: <p>I having trouble inserting a XML into SQL Server 2008. My Java Application creates a XML and trying to insert that into a Column of type "XML" under SQL Server 2008.</p>
  
  <p>It's throwing error</p>
  
  <pre><code>Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: XML parsing: line 1, character 39, unable to switch the encoding
  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
  at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:322)
  </code></pre>
  
  <p>This is the XML declaration </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-16" standalone="yes"?&gt;
  </code></pre>
  
  <p>I am not sure what XML encoding SQL Server 2008 expects to work fine.</p>
  
  <p>Can anyone suggest what should I try to resolve this?</p>