I want to create a job with two steps:
1. Success – go to step two, failure – exit(f).
2. Success – exit(s), failure – go to step one, but if this step fails more than once – exit(f).
Initial thought was to query some kind of job run id in step one, and if there are four (or more) rows for this id exit with failure, but there is no such thing as run id.
What is the best way to implement this logic?
Sql-server – Advanced job flow control
jobssql serversql server 2014
Related Question
- Sql-server – Any way to send notifications to different Emails on success/failure of SqlServerAgent job
- Sql-server – Bulk change Agent Jobs’ definition to “Quit the job reporting failure” from “Go to the next step” On Failure
- Sql-server – Stored procedures vs inline SQL in a Job step
- Sql-server – Question regarding flow control of SQL based jobs in SSIS
- Sql-server – Altering failed job email
- Sql-server – Handling ‘Variable not found’ in a tokenised job step
- Sql-server – Is conditional execution possible for SQL Server Agent job steps
- Sql-server – SQL Server Agent – Report Failure but continue When intermediate step fails
Best Answer
You can create duplicates of steps 1 and 2 as steps 3 and 4, and set the following flow:
But if you can instead wrap steps 1 and 2 in a stored procedure or ad hoc query that handles the retry logic without duplication, then your solution will be much more understandable and maintenance-safe.