共用方式為


修改與 SQL Server Agent 主要作業相關聯的目標伺服器

適用於:SQL Server

重要

Azure SQL 受控實例上,目前支援大部分但並非所有 SQL Server Agent 功能。 如需詳細資訊,請參閱 與 SQL Server 的 Azure SQL 受控實例 T-SQL 差異。

本主題描述如何使用 SQL Server Management Studio 或 Transact-SQL 修改與 SQL Server 中 SQL Server Agent 主要作業相關聯的目標伺服器。。

開始之前

限制與限制條件

SQL Server Agent 主要作業不能同時以本機和遠端伺服器為目標。

安全

權限

除非您是 系統管理員 固定伺服器角色的成員,否則您只能修改您擁有的工作。 For detailed information, see Implement SQL Server Agent Security.

使用 SQL Server Management Studio

修改與 SQL Server Agent 主要作業相關聯的目標伺服器

  1. In Object Explorer, click the plus sign to expand the server that contains the job where you want to modify the target server.

  2. Click the plus sign to expand SQL Server Agent.

  3. Click the plus sign to expand the Jobs folder.

  4. 在您想要修改目標伺服器的作業上按滑鼠右鍵,然後選取 [屬性]

  5. In the Job Properties -job_name dialog box, under Select a page, select Targets. 如您要此頁面可用選項的詳細資訊,請參閱 工作屬性 - 新增作業 (目標頁面)

  6. 完成後,按一下 [確定]

Using Transact-SQL

刪除目前與 SQL Server Agent 主要作業相關聯的目標伺服器

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

  2. On the Standard bar, click New Query.

  3. 將下列範例複製並貼到查詢視窗中,然後按下 [執行]

    -- removes the server SEATTLE2 from processing the Weekly Sales Backupsjob   
    -- assumes that the Weekly Sales Backups job exists  
    USE msdb ;  
    GO  
    
    EXEC sp_delete_jobserver  
        @job_name = N'Weekly Sales Backups',  
        @server_name = N'SEATTLE2' ;  
    GO  
    

如需詳細資訊,請參閱 sp_delete_jobserver (Transact-SQL)

將目標伺服器與目前的 SQL Server Agent 主要作業產生關聯

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

  2. On the Standard bar, click New Query.

  3. 將下列範例複製並貼到查詢視窗中,然後按下 [執行]

    -- assigns the multiserver job Weekly Sales Backups to the server SEATTLE2   
    -- assumes that the Weekly Sales Backups job already exists and that   
    -- SEATTLE2 is registered as a target server for the current instance  
    USE msdb ;  
    GO  
    
    EXEC dbo.sp_add_jobserver  
        @job_name = N'Weekly Sales Backups',  
        @server_name = N'SEATTLE2' ;  
    GO  
    

如需詳細資訊,請參閱 sp_add_jobserver (Transact-SQL)