Error Handling

  • Hi All,

    I am using SQL Server 2000. When an error happens in my stored proc, the process exits from the line of the code where error occurs so there is no way of knowing what the error was. I have used code like:

    if @@error <> 0

    begin

    set @step = 'error description'

    goto err

    end

    but it is not working. Can you help?

    Thanks.

  • Try your stored proc step by step and print message e.g. "Step1 completed" and / or "step1 started" for every possible step.

    Also you can use profiler for further investigation.

    Good Luck!

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • Thanks, SSRookie.

  • Put the error code into a variable so you can return it.

    SET @SQLError = @@ERROR

    IF @SQLError <> 0 .......

    You can then later query @SQLError and get the actual error number. Is this what you are after?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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