title: How to debug stored procedures with print statements?
body: <p>I am trying to debug stored procedures in SQL Server Management Studio 2008. I want to insert some print statements to test some IF-statements that I know are wrong.</p>
  
  <p>In order to do debugging, I tried using the <code>PRINT '5'</code> command.</p>
  
  <p>I tried using the <code>RAISERROR</code> like <code>'RAISERROR (N'Start',10,1) WITH NOWAIT'</code>. </p>
  
  <p>But these did not show any printouts, only the result set.  The message just says <code>1 row affected</code>.  </p>
  
  <p>I attempted to write the code like so (perhaps this is an incorrect approach):</p>
  
  <pre><code>SET NOCOUNT ON         
  RAISERROR (N'Start',10,1) WITH NOWAIT    
  DECLARE @DocHandle INT        
  DECLARE @PageSize INT, @PageIndex INT, @TOTL_CONT NUMERIC(5,0), @Paging BIT        
  DECLARE @Type INT, @Search varchar(20) , @ORDE nVARCHAR(50), @SORT_ID nVARCHAR(50) 
  DECLARE @CreatedOn varchar(25), @SystemGenerate bit   
  </code></pre>
  
  <p>What is the best way to use print statements to debug a stored procedure?</p>