SQL Server Availability Groups – Removing Database from AlwaysOn

availability-groupssql server

I have a 2-node SQL Server AlwaysOn Availability Group. When I execute this T-SQL command on the Primary server:

USE master 
go 
ALTER AVAILABILITY GROUP MyAG REMOVE DATABASE TestDB

it removes the TestDB from the Availability Group. Everything looks fine on the Primary server. However, on the Secondary replica, the TestDB has the status of "Restoring …" next to it. The database is inaccessible. The status remains "Restoring…" for a while. Looks like the only thing I could do is to drop it, which I did.

My question is: after I remove the DB from MyAG, what do I need to do to make the TestDB available for use again on the secondary replica?

Best Answer

Simply run

RESTORE DATABASE TestDB WITH RECOVERY

on the secondary.