the convenient solution has offered by BrandonGalde. Use it..
Main Topics
Browse All TopicsI have a SQL job that can take a variable length of time to run. I have another job that runs on a closer schedule. If the second job starts while the first is running, it will fail. I'd like to have the second job check for the first job running, and then either WAIT or not run at all.
Ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry folks - my question wasn't clear enough.
Job1 runs once a day and can take 30 minutes to 3 hours.
Job 2 runs every 2 hours and can take 5 minutes to 30 minutes.
If they collide, there's a problem. They both need to run independently of each other.
I'd like to have Job2 check to see if Job1 is running, and if so, then WAIT and/or fail that specific instance. I hope that clears up what I'm trying to achieve
In job 2, add an initial step with the following code (this assumes job1 has 3 steps. Change the 3 to the last job step that runs in the job):
Create a schedule in JOB2 called Main. Set it to run once with any date/time you want and disable it.
This code will pull the last run date (assuming time is irrelevant) and compare it with the current date. If the job has not yet run (or is running and has not completed), the date will be the previous run date. If that is the case, the schedule MAIN will be set to run in 15 minutes, will be enabled and the step will fail. Thus, the job will be run again in 15 minutes and will continue until JOB1 has run.
Business Accounts
Answer for Membership
by: BrandonGalderisiPosted on 2009-01-26 at 14:47:49ID: 23472025
Why not add the steps from Job 2 to Job 1?