how to quit an sproc

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rshivaraman@gmail.com

    how to quit an sproc

    Hi

    I am doing a check and on failing, i have a raiseerror command.
    I was assuming, once proc reaches raiseerror, it would stop the proc,
    but i see that the proc gives me an error message, but continues to
    run thru all the rest of the steps after raiseerror.
    how do i make the proc quit after reading raiseerror, only thru
    labels ?

    IF @CheckIFFileHas OnlyOneOutputTy pe 1
    BEGIN
    RAISERROR ('Process Stopped. Input xls file is invalid, as it has more
    than one output type specified in the OutputType Column', 16, 1)
    END
    --more proc steps are here ...

    Thanks in advance :
    RS

  • Erland Sommarskog

    #2
    Re: how to quit an sproc

    (rshivaraman@gm ail.com) writes:
    I am doing a check and on failing, i have a raiseerror command.
    I was assuming, once proc reaches raiseerror, it would stop the proc,
    but i see that the proc gives me an error message, but continues to
    run thru all the rest of the steps after raiseerror.
    how do i make the proc quit after reading raiseerror, only thru
    labels ?
    Which version of SQL Server are you using?

    In SQL 2000 you will need to use the RETURN statement. Preferrably you
    return a value 0, so that the caller knows that things went wrong.

    On SQL 2005 you can embed the code in BEGIN TRY END TRY, and then in
    BEGIN CATCH END CATCH have some generic error handling, including a
    RETURN statement.



    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server 2005 at

    Books Online for SQL Server 2000 at

    Comment

    Working...