Changing SQL Agent Job Schedule time programmaticaly doesn't work
I have an SQL Agent Job, that is supposed to be fired everyday at provided
time. If I change the schedule time manualy from Management Studio, it
works fine, but i need to change the time using stored procedure as below:
update s set
s.active_start_time = @time
from msdb..sysjobs j
left join msdb..sysjobschedules js on j.job_id = js.job_id
left join msdb..sysschedules s on js.schedule_id = s.schedule_id
where j.name = 'MyJobName'
Where I can provide start time in a requested format, and gues what? After
running such procedure, when I check scheduled time in Management Studio,
it's updated correctly, BUT obviously Job is ignores that.
I even run on a strange guess, that this Job keeps somewhere the old
schedule time that was set manually, and run using that one - if I for
example manually set time to 10:45 AM, and then quickly change time using
procedure to 10:55 AM, even if schedule time inside Management Studio
looks to be updated, Job still will run at 10:45...
Any thoughts what can be wrong?
No comments:
Post a Comment