title: Best Practices - Stored Procedure Logging
body: <p>If you have a long running SP, do you log somehow its actions or just wait for this message?</p>
  
  <blockquote>
    <p>"Command(s) completed successfully."</p>
  </blockquote>
  
  <p>I assume, that there can be plenty solutions on this subject, but is there any best practice - a simple solution that is frequently used?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've found an interesting link on this subject</p>
  
  <p><a href="http://weblogs.sqlteam.com/brettk/archive/2006/09/21/12391.aspx" rel="noreferrer">http://weblogs.sqlteam.com/brettk/archive/2006/09/21/12391.aspx</a></p>
  
  <p>Article describes using a log table, but there's an issue</p>
  
  <blockquote>
    <p>The logging procedure must be executed outside of any transaction</p>
  </blockquote>
  
  <p>I can't call that insert outside, because of cursor that I use and insert a line to that table on every row.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Digging..</p>
  
  <p>there's a <a href="http://msdn.microsoft.com/en-us/library/aa260695(SQL.80).aspx" rel="noreferrer"><strong>xp_logevent</strong></a> in SQL Server. Did you try it? </p>
  
  <p>What about <strong>SQL Server Profiler</strong>?</p>
  
  <p>There's also <a href="http://www.codeproject.com/KB/database/Stored_Procedure_Log_File.aspx" rel="noreferrer">Creating Log file for Stored Procedure</a>     </p>