how to trap an error from a system function?

  • I'm trying to add some code in a stored procedure to detect error from executing a function:

    set @variable = cast(@variable_2 as int)

    if (@@error != 0)

    do something ..

    However, it seems the error from the function termintate the excution of the whole stored procedure!

    Can anyone help?!

    Appreciated,

    Dakun

  • The attempt to cast a non-numeric to integer is what kills it with severity 16. You can't get around this other than avoiding the CAST. So, you should test for ISNUMERIC and any decimal points before trying a cast.

    Cheers,

    - Mark


    Cheers,
    - Mark

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

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