Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to auto-cancel jobs? 1

Status
Not open for further replies.

tigerjade

Programmer
Mar 17, 2004
237
US
I have some jobs that are s'posed to run nightly. They depend on an old ODBC driver that I can't get around, and this driver won't release the job when it's complete. So, the job will run once, and I have to cancel it the next day for it to run again that night. Is there a way to auto-terminate a job in Sql Server Agent?

thanks!

tigerjade

"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding


 
I had a similar issue many years ago ... here is what I did.

I first scripted out the job to a .sql file once I had tweaked it w/ the right steps, schedule and alerts.

I then created another job that I scheduled to run a couple of hours AFTER I knew the rouge job would have completed.

In this second job, I did the following (each per a step of the job )...

1. Stopped the rouge job w/ an sp_stop_job
2. Delete " " sp_delete_job
3. I then used an osql job that read my .sql text file that recreated the job. You can also embedd the create job script within the last step of the job.

Thanks

J. Kusch
 
JayKusch, you SO rock! Thanks a zillion and 3. :)

tigerjade

"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding


 
Here's the script I used to disable a job, but keep it in case I wanted to refer back to it later:

Code:
Exec sp_update_job @job_name = MyJob, @enabled = 0



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top