locked
How to disable a job from a t-sql command? RRS feed

  • Question

  • Hi, gurus,

    I wanna know if there is any way to disable a job from my SQL Server 2005 instance from a t-sql command? The reason why I ask is that while we are running some othere processes which do not allow me to disable the job from the interface.

    I just wonder if we can achieve it by any t-sql command? (I only want to disable it while still keep the job available on my SQL Server instance). Thanks. 

    Hope it is clear for your help.  

    Thanks a lot in advance for your help and I am looking forward to hearing from you shortly.   

    Best regards, 

    Yours sincerely,  

     

     

    Friday, October 3, 2008 2:36 PM

Answers

  • Hi:

     

       You can do it like this:

     

    Code Snippet
    EXEC msdb.dbo.sp_update_job @job_name='Your job name',@enabled = 0

     

     

     

    Hope this helps.
    Friday, October 3, 2008 3:06 PM

All replies

  • Hi:

     

       You can do it like this:

     

    Code Snippet
    EXEC msdb.dbo.sp_update_job @job_name='Your job name',@enabled = 0

     

     

     

    Hope this helps.
    Friday, October 3, 2008 3:06 PM
  •  

    Hi,

    Thanks a lot. It's great help Smile

    Best regards,

    Yours sincerely,

     

     

     

     

    Friday, October 3, 2008 3:35 PM
  • Hi,

    Can i update jobs of the other linked servers as well??

    Thursday, October 10, 2013 5:35 AM
  • Yes, you can as below:

    EXEC <YOURSERVERNAME>.msdb.dbo.sp_update_job
    
    			@job_name='SSIS_package_ReleaseMetrics',@enabled = 1



    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Thursday, October 10, 2013 5:41 AM