title: What is wrong with my Try Catch in T-SQL?
body: <p>I am using SQL Server 2008 and when I run this Statement in Management studio the Select statement in the Catch Block is executed as expected</p>
  
  <pre><code>BEGIN TRY
   INSERT INTO IDontExist(ProductID)
   VALUES(1)
  END TRY
  BEGIN CATCH
  SELECT 'There was an error! ' + ERROR_MESSAGE()
  END CATCH
  </code></pre>
  
  <p>However when I run this statement the statement in the Catch Block is never executed and instead the error is just displayed in the results tab</p>
  
  <pre><code>BEGIN TRY
    Select * from IDontExist
  END TRY
  BEGIN CATCH
    SELECT 'There was an error! ' + ERROR_MESSAGE()
  END CATCH
  </code></pre>
  
  <p>They both return the same error number '208' 'Invalid Object Name: IDontExist' so why would one get handled and the other not?</p>