Is it possible to enable or disable the sql server agent using t-sql?
Enable/Disable Sql Server Agent using a t-sql script
Asked Answered
exec msdb..sp_update_job @job_name = 'Job Name', @enabled = 0 --Disable
exec msdb..sp_update_job @job_name = 'Job Name', @enabled = 1 --Enable
Thanks! is there a way to enable/disable the agent itself too? –
Homiletics
You're welcome! And yes, google xp_servicecontrol (I've never use it). –
Abduction
You can use this to set it ON or OFF
EXEC xp_servicecontrol N'stop',N'SQLServerAGENT'
EXEC xp_servicecontrol N'start',N'SQLServerAGENT'
© 2022 - 2025 — McMap. All rights reserved.