exiting a procedure

  • I was wondering how to exit a procedure after I raise an error. This is what i'm doing. After a string is passed into the procedure if it is not valid I raise an error telling them that the string is not valid. However, after I catch the error I can't exit from the procedure so it contiues on. If anyone can help out on how i can exit from the procedure that would be great. Thanks Rich

    RICHARD KIRMSS


    RICHARD KIRMSS

  • Use error handler.

    Do all your error related processes there and then exit the procedure.

    Recently I posted a script for Error handling inside stored procedure:

    http://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=275

    Hope it will help you out.

    Edited by - EPol29 on 04/29/2002 10:22:51 AM

  • After a raiserror you must issue a return.

    Ex.

    if @STR IS NULL

    BEGIN

    RAISERROR('You must enter a search string',16,-1)

    RETURN

    END

    RestOfCode...

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • Thanks guys, I tried both ways and they both worked. Thank you again.

    RICHARD KIRMSS


    RICHARD KIRMSS

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

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