how to know whether a stored procedure run successfully or not

  • Hi Everybody,

    Can any one help me in finding whether a stored procedure run successfully or not. I am using sql server 2000. I am calling a sp in another sp. Basing on the status of the innner sp i need to do some operations.

    Thanks in advance.

    Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.:)

  • Hi

    It depends on how your inner procedure returns that something was not successfully. Your inner procedure can return a return code which can be handled in your outer procedure.

    Greets

    Flo

  • Here is a simple example:

    DECLARE @retval INT

    EXEC @retval = sys.sp_who

    IF @retval = 0 -- success

    BEGIN

    PRINT 'Success'

    END

    ELSE

    BEGIN

    PRINT 'Failure'

    END

    By default stored procedures return 0 for success, but you can specify any integer for the return value based on whay happend in your stored procedure.

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

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