title: SQL Server varchar(max) only 8k characters?
body: <p>I'm trying to execute a SQL query stored in a string. But the <code>varchar(max)</code> limit is only 8000. How can I store more than 8000 characters in SQL Server?</p>
  
  <pre><code>declare @query varchar(max)
  
  set @query = 'select * from ....... (22,000+ characters)'
  
  exec(@query)
  </code></pre>
  
  <p>Thanks!</p>