Muokkaa

Jaa


Modify the Target Servers for a Job

Applies to: SQL Server

Important

On Azure SQL Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Managed Instance T-SQL differences from SQL Server for details.

This topic describes how to change the target servers for Microsoft SQL Server Agent jobs in SQL Server by using SQL Server Management Studio or Transact-SQL.

Before You Begin

Security

Permissions

By default, members of the sysadmin fixed server role can execute this stored procedure. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:

  1. SQLAgentUserRole

  2. SQLAgentReaderRole

  3. SQLAgentOperatorRole

Using SQL Server Management Studio

To modify the target servers for 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, expand Jobs, right-click a job, and then click Properties.

  3. In the Job Properties dialog, select the Targetspage, and click Target local server, or Target multiple servers.

    If you choose Target multiple servers, designate the servers that will be targets for the job by checking the box to the left of the server name. Verify that the check boxes for servers that will not be targets of the job are unchecked.

Using Transact-SQL

To modify the target servers for a job

  1. Connect to the Database Engine.

  2. From the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute. This example assigns the multiserver job Weekly Sales Backups to the server SEATTLE2.

USE msdb ;  
GO  
  
EXEC dbo.sp_add_jobserver  
    @job_name = N'Weekly Sales Backups',   
    @server_name = N'SEATTLE2' ;   
GO  

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

See Also

Automated Administration Across an Enterprise