title: How can I capture the print message from a SQL Server stored procedure?
body: <p>Let say I have a stored procedure like this:</p>
  
  <pre><code>begin try drop procedure test_print end try begin catch end catch;
  go
  create procedure test_print
  as
  begin
  print 'Hello'
  print 'World';
  end
  go
  
  exec test_print
  </code></pre>
  
  <p>How can I capture the print messages in the stored procedure test_print and save it into a variable?</p>
  
  <p>Thanks.</p>