1

Currently I am creating a SQL Server job. My requirement is whenever the job fails, it needs to run one more time. Is it possible in SQL Server?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
bmsqldev
  • 2,627
  • 10
  • 31
  • 65
  • 1
    so you can some interval to run again. btw why you want to run it again? check this.. http://sqldbpool.com/2014/06/01/how-to-rerun-the-sql-agent-job-step-automatically-in-case-of-failure/ – Pedram Jan 21 '16 at 08:38
  • Its a requirement to run it again in case of failure. may be it is to ensure the job failed because of some configuration issues in the client db. thanks for the link – bmsqldev Jan 21 '16 at 08:57

1 Answers1

4

I'm not sure if this is the best way to do it, but you can configure every single step of a job to re-run a specific number of times after a specific number of minutes (in case of network troubles, for example). Open the step configuration in SQL Server Management Studio and set the "Retry attempts" and "Retry interval (minutes)" according to your preferences.

Of course, this will not work if you want to re-run the whole job from the beginning and it will not retry infinitely.

Onkel Toob
  • 2,152
  • 1
  • 17
  • 25
  • I am not getting your last words. It is not possible re-run the entire job in case of failure? – bmsqldev Jan 21 '16 at 08:58
  • With this solution you'll only re-run the one single job **step** that failed, which in most cases (but not all) will be fine because the previous steps worked correctly. Depends, however, on your job logic. – Onkel Toob Jan 21 '16 at 09:01
  • In other words, does your job only have one step or many? Please explain your job in more detail. Then go click around in the steps and you'll see what has been mentioned about retries. – Nick.Mc Jan 21 '16 at 10:51