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?
La 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
Autres conseils
You can use this to set it ON or OFF
EXEC xp_servicecontrol N'stop',N'SQLServerAGENT'
EXEC xp_servicecontrol N'start',N'SQLServerAGENT'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow