I need to disable all jobs running on a server. I ran the following code:
declare @t table (schedule_id int, [name] varchar(300))
update msdb.dbo.sysschedules
set enabled = 0
output inserted.schedule_id, inserted.name into @t
from msdb.dbo.sysjobs j
join msdb.dbo.sysjobschedules js
on j.job_id = js.job_id
join msdb.dbo.sysschedules s
on js.schedule_id = s.schedule_id
where j.[name] not like 'DB -%' and j.[name] not like 'sys%' and j.[name] not like 'Maintenance%'
select * from @t
When I check a given job and its associated schedule, either from the SQL Agent GUI, or through SQL, I can see the schedule is disabled. However, the jobs are still running, and I can see next run dates in the future if I check msdb.dbo.sysjobschedules.
The only things I've seen online suggest that there's a background thread that needs to be refreshed to pick up this change? And that do that, I need to run sp_sqlagent_refresh_job (did not help), or restart the server.
I can restart the server, but I'm curious if anyone else has seen this behavior, knows the cause, knows how to fix it another way.