title: IF, RAISERROR & RETURN in Stored Procedure
body: <p>I have a stored procedure, <code>PROC</code>, which receives some parameters. If one of them, <code>@ID</code>, is not null, a given stored procedure, <code>PROC_A</code>, must be executed. Otherwise, <code>PROC_B</code> must be executed. The problem is that both of them may issue a <code>RAISERROR</code>, which I want to propagate through the call stack to be displayed at the client application. However, that <code>RAISERROR</code> won't stop the rest of the <code>PROC</code> stored procedure as it should, and, since I am using an <code>IF</code> clause, checking <code>IF ( @@ERROR &lt;&gt; 0 ) RETURN</code> isn't an option either. My only choice seems to be using a <code>TRY...CATCH</code> block to wrap the <code>IF</code> clause and rethrow the <code>RAISERROR</code> from within the <code>CATCH</code> block, which is awkwards because then I will have to cache <code>ERROR_MESSAGE()</code>, <code>ERROR_SEVERITY()</code> and  <code>ERROR_STATE()</code> and use <code>RAISERROR</code> once again.</p>
  
  <p>Isn't there really any more elegant way?</p>