How to disable a job scheduled in task scheduler?

  • I would like to run a scheduled script to disable some jobs and enable then again in certain time. 

    Many thanks in advance.

  • This is what EM manager runs under the hood.  That should get you stared :

    BEGIN TRANSACTION           

      DECLARE @JobID BINARY(16) 

      DECLARE @ReturnCode INT   

      SELECT @ReturnCode = 0    

      SELECT @JobID = 0x4E08C391E248BB4296CBFF36C997ED9D

      EXECUTE @ReturnCode = msdb.dbo.sp_update_jobschedule @job_id = @JobID, @name = N'MAIN', @new_name = N'MAIN', @enabled = 1, @freq_type = 4, @active_start_date = 20061012, @active_start_time = 233000, @freq_interval = 1, @freq_subday_type = 1, @freq_subday_interval = 0, @freq_relative_interval = 0, @freq_recurrence_factor = 0, @active_end_date = 99991231, @active_end_time = 235959

      IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

    COMMIT TRANSACTION         

  • Probably, I did not make it clear. The jobs I would like to handle are on the Windows level.

  • How about this : Here I have a job that is run every day.  This job writes a batch file that move files around.  Maybe you could do something similar where you either create (or rename / move) the job file or do as I did with a batch file.

    Hope this helps .

  • Looks the widows AT command help...

    You can exeucte AT commad with the help of xp_cmdshell if you want to do with sql server...

     

    MohammedU
    Microsoft SQL Server MVP

  • Would using the "AT" command be considered an acceptable alternative to the Windows Scheduled Task method in your environment? If so, it would be much easier to disable them through a variety of methods, including batch files called from jobs, etc.

  • Thank you for your inputs. But it seems that we still do not any have solution yet.

  • Still have or still don't have?

Viewing 8 posts - 1 through 7 (of 7 total)

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