Udostępnij za pośrednictwem


Disable or Enable a Job

This topic describes how to disable a SQL Server Agent job in SQL Server 2012 by using SQL Server Management Studio or Transact-SQL. When you disable a job, it is not deleted and can be enabled again when necessary.

In This Topic

  • Before you begin:

    Security

  • To disable or enable a job, using:

    SQL Server Management Studio

    Transact-SQL

Before You Begin

Security

For detailed information, see Implement SQL Server Agent Security.

Ikona strzałki używana z łączem Powrót na górę strony[Top]

Using SQL Server Management Studio

To disable or enable a job

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.

  2. Expand SQL Server Agent.

  3. Expand Jobs, and then right-click the job that you want to disable or enable.

  4. To disable a job, click Disable. To enable a job, click Enable.

Ikona strzałki używana z łączem Powrót na górę strony[Top]

Using Transact-SQL

To disable or enable a job

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    -- changes the name, description, and enables status of the job NightlyBackups.
    USE msdb ;
    GO
    
    EXEC dbo.sp_update_job
        @job_name = N'NightlyBackups',
        @new_name = N'NightlyBackups -- Disabled',
        @description = N'Nightly backups disabled during server migration.',
        @enabled = 1 ;
    GO
    

For more information, see sp_update_job (Transact-SQL).

Ikona strzałki używana z łączem Powrót na górę strony[Top]