Job Schedule change

  • I am using the following script to change the job schedule dynamically to 8:15AM 8:20AM and 9PM. Even though it's changing the job schedule the job doesn't seems to be kicking off..I appreciate your comment on this

    Declare @Active_Start_Date varchar(15)

    Select @Active_Start_Date = Active_Start_Date from msdb..sysjobschedules

    Where Schedule_ID = 137

    If DATEPART(dd,GETDATE())Between 20 And 22 --Change it to 12 AND 15 later

    UPDATE msdb..sysjobschedules

    SET Active_Start_Time = 82000,

    Next_Run_Date = @Active_Start_Date,

    Next_Run_Time = 82500

    Where Schedule_ID = 137

    Else

    UPDATE msdb..sysjobschedules

    SET Active_Start_Time = 210000,

    Next_Run_Time = 21000

    Where Schedule_ID = 137

    Shas3

  • for this task you should use:

    exec msdb..sp_update_jobschedule ...

    Besides the changes to the schedule values it is important to maintain the version, to notify sql agent for data refresh and to perform some extra checkings related to replication and data integrity. ALL that is done for you by this procedure and you should not need to access that table directly.

    HTH

     


    * Noel

  • Why not just schedule it to run at those times and be done with it ??

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply