title: Passing error details from catch into log stored procedure
body: <p>I have a stored procedure in SQL Server with try catch.  What I want to do in the catch loop is to call my own Stored procedure for logging with all the error variables, like so:</p>
  
  <pre><code>BEGIN TRY
      -- Generate a divide-by-zero error.
      SELECT 1/0;
  END TRY
  BEGIN CATCH
      exec log.LogError ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_MESSAGE();
  END CATCH;
  </code></pre>
  
  <p>When I run this I get an error on the parenthesis.</p>
  
  <p>I can run:</p>
  
  <pre><code>select ERROR_NUMBER(), ERROR_SEVERITY(), ERROR_MESSAGE();
  </code></pre>
  
  <p>I can also do</p>
  
  <pre><code>print ERROR_NUMBER()
  </code></pre>
  
  <p>What I want to do is the have just one line which calles the stored procedure with the parameters because I will have this in many stored procedures and don't want to have lot's of code setting the error parameters (I will have more than these three) in each stored procedure where I have try-catch.</p>
  
  <p>Does anybody know how I can pass these into another stored procedure?</p>
  
  <p>Regards,
  Johann</p>