Remove an Availability Group Listener (SQL Server)
This topic describes how to remove an availability group listener from an AlwaysOn availability group by using SQL Server Management Studio, Transact-SQL, or PowerShell in SQL Server 2012.
-
Before you begin:
-
To remove a listener, using:
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.
Security
To remove an availability group listener
-
In Object Explorer, connect to the server instance that hosts the primary replica, and click the server name to expand the server tree.
-
Expand the AlwaysOn High Availability node and the Availability Groups node.
-
Expand the node of the availability group, and expand the Availability Groups Listeners node.
-
Right-click the listener to be removed, and select the Delete command.
-
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)
To remove an availability group listener
-
Connect to the server instance that hosts the primary replica.
-
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’;
To remove an availability group listener
-
Set default (cd) to the server instance that hosts the primary replica.
-
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
NoteTo 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.
