TRY & CATCH

  • i am catching error's in a STORED PROCEDURE using TRY/CATCH.

    I want to continue receiving errors in certain instances while still using TRY/CATCH

    what is the right way to do it?

    Thanks

    Peleg

  • You can just raise an error in the CATCH block.

  • Here's how you can do it:

    begin try

    declare @varchar varchar(100)

    set @varchar = 1 + 'This will error out'

    end try

    begin catch

    Declare @ERROR_MESSAGE varchar(max)

    set @ERROR_MESSAGE = ERROR_MESSAGE()

    RAISERROR(@ERROR_MESSAGE,11,1)

    end catch

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply