jobs.sp_add_target_group (Azure Elastic Jobs) (Transact-SQL)
Applies to: Azure SQL Database
Creates a target group for jobs in the Azure Elastic Jobs service for Azure SQL Database.
Target groups provide an easy way to target a job at a collection of servers and/or databases.
Transact-SQL syntax conventions
Syntax
[jobs].sp_add_target_group
@target_group_name = 'target_group_name'
[ , [ @target_group_id = ] target_group_id OUTPUT ]
Arguments
@target_group_name
The name of the target group to create. target_group_name is nvarchar(128), with no default.
@target_group_id OUTPUT
The target group identification number assigned to the job if created successfully. target_group_id is an output variable of type uniqueidentifier, with a default of NULL
.
Return code values
0
(success) or 1
(failure).
Remarks
Use jobs.sp_add_target_group_member to add members to a target group.
Permissions
By default, members of the sysadmin fixed server role can execute this stored procedure. Only members of sysadmin can use this stored procedure to edit the attributes of jobs that are owned by other users.
Examples
Create a target group
The following example creates a target group named ServerGroup1
.
-- Add a target group containing server(s)
EXEC [jobs].sp_add_target_group @target_group_name = N'ServerGroup1';