Question

Is it possible to enable or disable the sql server agent using t-sql?

Was it helpful?

Solution

exec msdb..sp_update_job @job_name = 'Job Name', @enabled = 0 --Disable
exec msdb..sp_update_job @job_name = 'Job Name', @enabled = 1 --Enable

OTHER TIPS

You can use this to set it ON or OFF

   EXEC xp_servicecontrol N'stop',N'SQLServerAGENT'
   EXEC xp_servicecontrol N'start',N'SQLServerAGENT'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top