• kenneth.mofokeng (10/9/2013)


    Use TRY and CATCH

    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

    check BOL

    http://technet.microsoft.com/en-us/library/ms130214.aspx

    Eish, Kenneth my bra.

    That example in books online shows how control is NOT passed to the catch block.

    You missed the surrounding text on the example:

    The following example shows how an object name resolution error generated by a SELECT statement is not caught by the TRY…CATCH construct.

    The error is not caught and control passes out of the TRY…CATCH construct to the next higher level.

    Eita

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]