raiserror - terminate proc?

  • Hi,

    I am under the impression that raiserror will not stop the execution of a stored procedure. I am seeing just the opposite happen, when executing the proc with raiserror statements via an Agent job.

    I have a proc containing raiserrors. I want the proc to continue on after it encounters an error. If I run the contents of the proc in a Query Analyzer window, it does just this. However, if I execute the actual proc called by an Agent job, it stops at first error.

    My goal is to run the job which executes the proc to completion, and have the job fail if it encountered a raiserror along the way. I know I could use @@error to a variable and manage it this way, but I am trying to understand why it is stopping when I've read that raiserror has no effect on termination of the proc. Is what I've read incorrect?

    Here's the example of the raiserror I am using:

    RAISERROR ('Move file verification: ERROR! File %s DOES NOT exist in pickup location.',16,1,@fullfilename)

    Thank you,

    Sharon

  • Here's some more info as I just tested a bit more:

    run the contents of proc in Query Analyzer - doesn't terminate on raiserror

    run the actual proc in Query Analyzer via "exec procname"- doesn't terminate on raiserror

    run the actual proc from an Agent job via "exec procname"- DOES terminate on first raiserror.

    Why does the Agent handle this differently?

    Thanks in advance,

    Sharon

  • There's some info on the following link that may help:

    http://support.microsoft.com/kb/309802

    Hope it does 🙂

    Atlantis Interactive - SQL Server Tools
    My blog[/url]
    Why I wrote a sql query analyzer clone

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

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