title: How to store a string var greater than varchar(max)?
body: <p>I'm trying to do this:</p>
  
  <pre><code>DECLARE @myVar VARCHAR(MAX)
  Loop with cursor
  select @myVar = @myVar + bla bla bla
  end loop
  </code></pre>
  
  <p>When the loop ends, @myVar is incomplete, containing only 8000 characters.</p>
  
  <p>I have tryed to use text, but is not allowed to local vars.</p>
  
  <p>What would be a good solution to this case?  </p>
  
  <p>xml var?</p>
  
  <p>I have just looked this posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/284610/how-do-i-pass-a-string-parameter-greater-than-varchar8000-in-sql-server-2000">How do I pass a string parameter greater than varchar(8000) in SQL Server 2000?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2975165/check-if-concatenating-to-a-varcharmax-will-go-beyond-max-allowable-characters">Check if concatenating to a varchar(max) will go beyond max allowable characters</a></p>
  
  <p>And others through the web.</p>
  
  <p>Regards.</p>