How to Enable or Disable SQL Server Agent Job and How to Start Job at Later days - SQL Server DBA Tutorial

In this video you will learn multiple ways of how to enable and disable SQL Server Agent Job, how to schedule jobs that would run in later hours using SQL Server Management Studio as well as T-SQL script. It also explains how to enable or disable Job Schedule as well as how to update SQL Server Agent Job Schedule.

Scripts to Enable or Disable SQL Server Agent Jobs or Schedule to Start Later on Schedule

--disable Job
USE msdb ;
GO

EXEC dbo.sp_update_job
    @job_name = N'BackupAlldb',
   @enabled = 0 ;
GO

--enable job
EXEC dbo.sp_update_job
    @job_name = N'BackupAlldb',
   @enabled = 1 ;

   --Enable Job Schedule
   EXEC dbo.sp_update_schedule
    @name = 'WeeklyRun',
    @enabled = 0

    -- Disable Job Schedule
      EXEC dbo.sp_update_schedule
    @name = 'WeeklyRun',
    @enabled = 1

    --Start Schedule at Later date (04/04/2015)
    USE [msdb]
GO
EXEC msdb.dbo.sp_update_schedule @name=WeeklyRun, 
        @active_start_date=20150404
GO


How to Enable or Disable SQL Server Agent Job in SQL Server

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.