Enable/Disable Sql Server Agent using a t-sql script
-
01-06-2021 - |
Question
Is it possible to enable or disable the sql server agent using t-sql?
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