title: In SQL Server, what is the best way to determine if a given string is a valid XML or not?
body: <p>A third party component is filling up an <code>nvarchar</code> column in a table with some values. Most of the time it is a human-readable string, but occassionally it is XML (in case of some inner exceptions in the 3rd party comp). </p>
  
  <p>As a temporary solution (until they fix it and use string always), I would like to parse the XML data and extract the actual message. </p>
  
  <p><strong>Environment:</strong> SQL Server 2005; strings are always less than 1K in size; there could be a few thousand rows in this table. </p>
  
  <hr>
  
  <p>I came across a couple of solutions, but I'm not sure if they are good enough: </p>
  
  <ol>
  <li>Invoke <code>sp_xml_preparedocument</code> stored proc and wrap it around TRY/CATCH block. Check for the return value/handle.</li>
  <li>Write managed code (in C#), again exception handling and see if it is a valid string.</li>
  </ol>
  
  <p>None of these methods seem efficient. I was looking for somethig similar to <code>ISNUMERIC()</code>: an <code>ISXML()</code> function.  Is there any other better way of checking the string?</p>