Applies a job to one or more target servers or to the target servers belonging to one or more target server groups.
sp_apply_job_to_targets [@job_id =] job_id | [@job_name =] 'job_name'
[, [@target_server_groups =] 'target_server_groups']
[, [@target_servers =] 'target_servers']
[, [@operation =] 'operation']
Note Either job_id or job_name must be specified, but both cannot be specified.
0 (success) or 1 (failure)
None
sp_apply_job_to_targets provides an easy way to apply (or remove) a job from multiple target servers, and is an alternative to calling sp_add_jobserver (or sp_delete_jobserver) once for each target server required.
Only members of the sysadmin fixed server role can execute sp_apply_job_to_targets.
This example applies the previously created Backup Customer Information job to all the target servers in the Servers Maintaining Customer Information group.
USE msdb
EXEC sp_apply_job_to_targets @job_name = 'Backup Customer Information', @target_server_groups = 'Servers Maintaining Customer Information',
@operation = 'APPLY'
sp_add_jobserver | sp_remove_job_from_targets |
sp_delete_jobserver | System Stored Procedures |