Sql-server – Zombie Sql Server DB on Secondary Replica is both in and out of an Availability Group

availability-groupssql-server-2012

I have a database in SQL Server 2012 that is on the secondary replica of an availability group. I removed the database from the AG db list on the primary and the db is currently in the Restoring state on the secondary.

The problem is that I'm unable to drop the database off the secondary.

DROP DATABASE [ZOMBIEDB]

Gives me the following error:

"The database 'ZOMBIEDB' is currently joined to an availability group.
Before you can drop the database, you need to remove it from the
availatility group."

However:

ALTER DATABASE [ZOMBIEDB] SET HADR OFF;

Yields the following error:

"Cannot complete this ALTER DATABASE SET HADR
operation on database 'ZOMBIEDB'. The database is not joined to an
availability group. After the database has joined the availability
group, retry the command."

So, how do I convince SQL Server that the db isn't in an AG so I can drop it?

Best Answer

I pulled the oldest full backup I could find and was able to restore that over the Restoring db using:

RESTORE DATABASE [ZOMBIEDB] FROM  DISK = N'D:\ZOMBIEDB.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 5

I was then able to delete the restored database.