Remove an availability group listener (SQL Server)

Applies to: SQL Server

This topic describes how to remove an availability group listener from an Always On availability group by using SQL Server Management Studio, Transact-SQL, or PowerShell in SQL Server.

Prerequisites

  • You must be connected to the server instance that hosts the primary replica.

Recommendations

Before you delete an availability group listener, we recommend that you ensure that no applications are using it.

Permissions

Requires ALTER AVAILABILITY GROUP permission on the availability group, CONTROL AVAILABILITY GROUP permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.

Using SQL Server Management Studio

To remove an availability group listener

  1. In Object Explorer, connect to the server instance that hosts the primary replica, and click the server name to expand the server tree.

  2. Expand the Always On High Availability node and the Availability Groups node.

  3. Expand the node of the availability group, and expand the Availability Groups Listeners node.

  4. Right-click the listener to be removed, and select the Delete command.

  5. This opens the Remove Listener from Availability Group dialog box. For more information, see Remove Listener from Availability Group, later in this topic.

Remove Listener from Availability Group (Dialog Box)

Name
The name of the listener to be removed.

Result
Displays a link, either Success or Error, which you can click for more information.

Using Transact-SQL

To remove an availability group listener

  1. Connect to the server instance that hosts the primary replica.

  2. Use the ALTER AVAILABILITY GROUP statement, as follows:

    ALTER AVAILABILITY GROUP group_name REMOVE LISTENER 'dns_name'

    where group_name is the name of the availability group and dns_name is the DNS name of the availability group listener.

    The following example deletes the listener of the AccountsAG availability group. The DNS name is AccountsAG_Listener.

    ALTER AVAILABILITY GROUP AccountsAG REMOVE LISTENER 'AccountsAG_Listener';  
    

Using PowerShell

To remove an availability group listener

  1. Set default (cd) to the server instance that hosts the primary replica.

  2. Use the built in Remove-Item cmdlet to remove a listener. For example, the following command removes a listener named MyListener from an availability group named MyAg.

    Remove-Item `   
    SQLSERVER:\Sql\PrimaryServer\InstanceName\AvailabilityGroups\MyAg\AGListeners\MyListener  
    

    Note

    To view the syntax of a cmdlet, use the Get-Help cmdlet in the SQL Server PowerShell environment. For more information, see Get Help SQL Server PowerShell.

Related Tasks

See Also

Overview of Always On Availability Groups (SQL Server)
Availability Group Listeners, Client Connectivity, and Application Failover (SQL Server)