sp_remove_job_from_targets

Transact-SQL Reference

Transact-SQL Reference

sp_remove_job_from_targets

Removes the specified job from the given target servers or target server groups.

Syntax

sp_remove_job_from_targets [ @job_id = ] job_id
    | [ @job_name = ] 'job_name'
    [ , [ @target_server_groups = ] 'target_server_groups' ]
    [ , [ @target_servers = ] 'target_servers' ]

Arguments

[@job_id =] job_id

Is the job identification number of the job from which to remove the specified target servers or target server groups. Either job_id or job_name must be specified, but both cannot be specified. job_id is uniqueidentifier, with a default of NULL.

[@job_name =] 'job_name'

Is the name of the job from which to remove the specified target servers or target server groups. Either job_id or job_name must be specified, but both cannot be specified. job_name is sysname, with a default of NULL.

[@target_server_groups =] 'target_server_groups'

Is a comma-separated list of target server groups to be removed from the specified job. target_server_groups is nvarchar(1024), with a default of NULL.

[@target_servers =] 'target_servers'

Is a comma-separated list of target servers to be removed from the specified job. target_servers is nvarchar(1024), with a default of NULL.

Return Code Values

0 (success) or 1 (failure)

Permissions

Only members of the sysadmin fixed server role can execute sp_remove_job_from_targets.

Examples

This example removes the previously created Weekly Sales Data Backup job from the Sales Server target server group, and from the SEATTLE1 and SEATTLE2 servers.

USE msdb
EXEC sp_remove_job_from_targets @job_name = 'Weekly Sales Data Backup',
   @target_servers = 'Sales Servers', 
   @target_server_groups = 'SEATTLE2,SEATTLE1'

See Also

sp_apply_job_to_targets

sp_delete_jobserver

System Stored Procedures