Reporting failure in a Job

  • we have some jobs that execute stored procedures. these procedures return non-zero value when an error occurs. and we'd like to abort the job when an error happens inside a stored procedure.

    here is simplified example.

    Stored procedure spDoSomething

    ---------------------------

    Do something

    If @error <> 0 return 1

    else return 0

    ---------------------------------

    inside a job called job Job_1, one of the steps is

    exec spDoSomething.

    what we want is when spDoSomething returns 1, Job_1 will abort and report Job_1 failed. when viewing the history of the job, it shows the job failed.

    Thank you very much for your help.

     

     

  • it works.

    thanks a lot.

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

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