Solution:
I've misinterpreted the example from SQL Books Online. Yes, that below the section Errors Unaffected by a TRY…CATCH Construct ... I'm so sorry :(
I was just trying to execute this simple example in SQL Server Management Studio:
USE AdventureWorks;
GO
BEGIN TRY
-- Table does not exist; object name resolution
-- error not caught.
SELECT * FROM NonexistentTable;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() as ErrorNumber,
ERROR_MESSAGE() as ErrorMessage;
END CATCH
But the only thing I find as output is:
Msg 208, Level 16, State 1, Line 5 Invalid object name 'NonexistentTable'.
So, the error seems to be captured by the SQL Server Management Studio instead of the catch block, which is obviously not what I expected. Am I missing something?
Thanks in advance :)