title: T-SQL Clear Errors
body: <p>I'm trying to clean up a huge legacy T-SQL stored proc. We call it from BizTalk.  BizTalk has a feature to retry a send port (for example 3 times every 5 minutes) when it is in error. </p>
  
  <p>For example, the stored proc detects missing data and does this: </p>
  
  <pre><code>   if @CompanyID is null        raiserror( '@CompanyID is missing', 18, 1 );
  </code></pre>
  
  <p>The "Begin Catch" logic handles certain errors, (i.e. logs them to error tables), and then does a "Return 0".  I believe the prior programmer thought this would keep BizTalk from calling it again.  But now I have a trace and I can prove that BizTalk is calling it x retries every y minutes apart (as defined by the BizTalk SendPort). </p>
  
  <p>My current thought is that if @@Error and @@ErrorMessage are not null, BizTalk still thinks it is in error, and will retry. </p>
  
  <p>Any thoughts on how to totally clear the errors?  I was hoping to do a small quick fix, no time for a major rewrite. </p>