How to recognize and start a job if another job step is succesful?

  • Hi Experts,

    I have a maintenance job which has many job steps - checkdb, backup, rebuild index, etc...

    I was asked to setup a job which will copy all backup files to a central location.

    Now I wrote the script and its working good (part of a new job step)

    But, I am now thinking to add some more logic in the job step:-

    that is, if the previous job (server maintenance) is successfully completed with the backup job (if completed succesfully), then only the copy to location job will start, if the other job step is failed, my copy bkp job will not run

    Any advise/suggestion how to do it?? (Just an enhancement to my existing job).

    Cheers to all of you

    Thanks.

  • You can query the job history from msdb.dbo.sysjobhistory. Here is a link to an article that describes in more detail.

    http://www.mssqltips.com/sqlservertip/2850/querying-sql-server-agent-job-history-data/

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Why not just put it as the next step in your job after the DB back up and configure your job to skip or fail if the back up step failed? Or is that you want the back up copy to run in parallel with the next steps in your maint job? Querying msdb.dbo.sysjobhistory is definitely an option, you would want to check the run_status value for success. Unfortunately run_date is not a date field, so you have to format it.

    MWise

  • thnx for all your response. I'll better check the status of the first job using sysjobhistory and use that value to the other job. Thnx Indeed. Bye

    Thanks.

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

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