title: SQL won't print out my variable
body: <p>I'm working with a SQL stored procedure and dynamic SQL. When I try to debug everything works fine, up until when I'm printing my @columnName.</p>
  
  <p>this is the part of the code that's causing trouble:</p>
  
  <pre><code>DECLARE @query NVARCHAR(2000)
  DECLARE @columnName NVARCHAR(250)
  SELECT @query = 'SELECT myTable.value FROM myTable WHERE myConditions'
      EXECUTE sp_executesql @query, N'@columnName NVARCHAR(30) OUTPUT', @columnName OUTPUT
      PRINT N'query='+@query
      set @query = ''
      PRINT N'query after reset='+@query
      PRINT N'columnName='+@columnName
      PRINT N'any other message'
  Select @query = 'SELECT myValues AS '''+@columnName+''',
                   FROM myTable2
                   WHERE myConditions';
  EXEC(@query);
  </code></pre>
  
  <p>This is the output messages:</p>
  
  <pre><code>query=SELECT myTable.value FROM myTable WHERE myConditions
  query after reset=
  
  any other message
  </code></pre>
  
  <p>So, where is my <code>columnName=</code> output?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p><em>SQL Version:</em> Microsoft SQL Server 2012 - 11.0.2100.60 (X64) 
      Feb 10 2012 19:39:15 
      Copyright (c) Microsoft Corporation
      Standard Edition (64-bit) on Windows NT 6.1  (Build 7601: Service Pack 1) (Hypervisor)</p>