title: Printing more than 8000 characters in text output
body: <p>There is a limit to the print output on MS SQL server (I'm using SQL Server 2014).</p>
  
  <p>I've got my Maximum number of characters displayed in each column set to 8192 (the max). When I try to set a variable to a long string and print it, it gets truncated. With output set to text:</p>
  
  <pre><code>declare @text nvarchar(max)
  set @text = (
               select definition
                 from sys.sql_modules
                where object_id = object_id(N'NameOfALargeStoredProcedure')
              )
  print @text
  </code></pre>
  
  <p>This will return about 4K of the characters. If I change <code>@text</code> to <code>varchar</code> (instead of <code>nvarchar</code>) I get around 8K characters.</p>
  
  <p>The definition of the procedure is much larger than 8K. I need to print the entire text of a string that is larger than 8K.</p>
  
  <p>I know SQL Server has a built-in script object feature. What I need to print may not be a database object: I need to print an arbitrary string.</p>