title: How do I convert an XML field with more than 8000 characters into a string?
body: <p>I have a SQL Server column of type <code>XML</code> containing some records with more than 8000 characters.</p>
  
  <p>I would like to convert this column into a <code>varchar</code>.</p>
  
  <p>I am not concerned about truncation (the first 8000 characters is fine).</p>
  
  <p>However, whenever I try <code>CONVERT(varchar(8000), Content)</code> I get an error:</p>
  
  <blockquote>
    <p>Target string size is too small to represent the XML instance</p>
  </blockquote>
  
  <p>When I try <code>CONVERT(varchar(MAX), Content)</code> I get an error:</p>
  
  <blockquote>
    <p>String or binary data would be truncated</p>
  </blockquote>
  
  <p>When I try <code>CONVERT(varchar(20000), Content)</code> I get an error:</p>
  
  <blockquote>
    <p>The size (20000) given to the type 'varchar' exceeds the maximum allowed for any data type (8000)</p>
  </blockquote>
  
  <p>When I try <code>CONVERT(text, Content)</code> I get an error:</p>
  
  <blockquote>
    <p>Explicit conversion from data type xml to text is not allowed</p>
  </blockquote>
  
  <p>Is there a workaround?</p>