Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Script for Stop the Job if running and disable

Author  Topic 

snivas
Starting Member

9 Posts

Posted - 2011-12-06 : 09:43:16
Dear all,

I am not familiar with Progamming,
I need help from guru's
I want a script which can stop the Jobs If jobs are running and disable jobs,If Job is not running script should Disable the Job.

can some help me with script it is greate help for me.


Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 10:43:17
use sp_stop_job to stop a job programatically

for disabling enabling see

http://www.mssqltips.com/sqlservertip/1400/disabling-or-enabling-sql-server-agent-jobs/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

snivas
Starting Member

9 Posts

Posted - 2011-12-07 : 06:29:41
Hey visakh

If I disable the Job which is running it will stop the Job ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-07 : 06:42:24
quote:
Originally posted by snivas

Hey visakh

If I disable the Job which is running it will stop the Job ?


nope it wont
the current run will still be completed
further runs wont occur

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -