jobs.sp_delete_target_group_member (Azure Elastic Jobs) (Transact-SQL)

Applies to: Azure SQL Database

Removes a database or group of databases from a target group in the Azure Elastic Jobs service for Azure SQL Database.

Transact-SQL syntax conventions

Syntax

[jobs].sp_delete_target_group_member [ @target_group_name = ] 'target_group_name'
   [ , [ @target_id = ] 'target_id']

Arguments

@target_group_name

The name of the target group from which to remove the target group member. target_group_name is nvarchar(128), with no default.

@target_id

The target identification number assigned to the target group member to be removed. target_id is a uniqueidentifier, with a default of NULL.

Return Code Values

0 (success) or 1 (failure)

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

Remove a server from a target group

The following example removes the London server from the group "Servers Maintaining Customer Information". You must connect to the jobs database specified when creating the job agent, in this case ElasticJobs.

--Connect to the jobs database specified when creating the job agent
USE ElasticJobs ;
GO

-- Retrieve the target_id for a target_group_members
DECLARE @tid uniqueidentifier
SELECT @tid = target_id 
FROM [jobs].target_group_members 
WHERE target_group_name = 'Servers Maintaining Customer Information' 
AND server_name = 'London.database.windows.net';

-- Remove a target group member of type server
EXEC jobs.sp_delete_target_group_member
@target_group_name = N'Servers Maintaining Customer Information',
@target_id = @tid;
GO