title: Set EXECUTE sp_executesql result into a variable in sql
body: <p>I have to set a dynamic sql query result to a variable. My sql query is :</p>
  
  <pre><code>DECLARE @ResultString NVARCHAR(MAX)
  DECLARE @Qry NVARCHAR(MAX)  
  
  SET @Qry='SELECT Test FROM MTest22Dec WHERE ID = 1'      
  EXECUTE sp_executesql @Qry, N'@Result NVARCHAR(MAX) OUTPUT', @Result=@ResultString OUTPUT
  PRINT @ResultString
  </code></pre>
  
  <p>But <code>@ResultString</code> is printing empty string although there is record in database table.</p>
  
  <p>What is wrong in this query?</p>
  
  <p>thanks</p>