title: SQL Server TRY CATCH FINALLY
body: <p>I have a scenario where I need something similar to <code>.NET's try-catch-finally block.</code></p>
  
  <p>On my try, I will <code>CREATE a #temp table</code>, <code>INSERT</code> data to it &amp; process other data sets based on <code>#temp</code>.</p>
  
  <p>On <code>CATCH</code> then <code>RAISERROR</code>.
  Is it possible to have a <code>FINALLY</code> block to <code>DROP #temp</code>?
  Below is the pseudo code:</p>
  
  <pre><code>BEGIN TRY
  
    CREATE TABLE #temp
    (
       --columns
    )
    --Process data with other data sets
  
  END TRY
  BEGIN CATCH
  
    EXECUTE usp_getErrorMessage
  
  END CATCH
  BEGIN FINALLY
  
    DROP TABLE #temp
  
  END FINALLY
  </code></pre>