SQL Server error 956 means the database you are trying to use is still flagged as enabled for database mirroring, even though the mirroring session is no longer active. The fix is to remove the mirroring metadata from the database and, if needed, from the server instance. You do this with ALTER DATABASE ... SET PARTNER OFF and, when the database is stuck in a restoring or recovering state, by restoring the database with WITH RECOVERY or dropping and re-adding it. The exact path depends on whether the mirroring endpoint or the partner metadata is the problem, so work through the steps in order and stop as soon as the error clears.
What You'll Need
- Membership in the sysadmin fixed server role or equivalent permissions on both the principal and mirror server instances.
- The database name and the names of the server instances involved in the old mirroring session.
- A recent backup of the database, because removing mirroring metadata and restoring are destructive operations.
- SQL Server Management Studio (SSMS) or another client that can run T-SQL against the instance.
Step-by-Step
- Confirm the error and the database state. Connect to the instance in SSMS and run
SELECT name, state_desc, mirroring_state_desc FROM sys.databases WHERE name = 'YourDatabase';. A database that returns a mirroring state ofSYNCHRONIZED,SUSPENDED, orPENDING_FAILOVERwhile the partner is gone is a strong sign the metadata is stale. Ifstate_descisRESTORINGorRECOVERING, the database is still waiting for mirroring or restore completion. - Remove the mirroring partner on the principal. In a query window against the principal instance, run
ALTER DATABASE [YourDatabase] SET PARTNER OFF;. This removes the mirroring configuration and the partner metadata from the database. If the command succeeds, the database is no longer enabled for mirroring and error 956 should stop appearing. - Remove the mirroring partner on the mirror, if it still exists. If the mirror instance is reachable, connect to it and run the same command:
ALTER DATABASE [YourDatabase] SET PARTNER OFF;. On a mirror that is still in a restoring state, this may fail; in that case move to the next step. - Drop the mirroring endpoint if it is no longer needed. On each instance that hosted the old session, check for the endpoint with
SELECT name, state_desc FROM sys.database_mirroring_endpoints;. If the endpoint is unused, remove it withDROP ENDPOINT [Mirroring];. Only do this if no other database on that instance uses the endpoint for mirroring. - Recover a database stuck in RESTORING. If the database is in a restoring state and you do not intend to resume mirroring, restore the latest full backup over it with
RESTORE DATABASE [YourDatabase] WITH RECOVERY;. This brings the database online and clears the mirroring metadata. Warn: this replaces the current database contents, so confirm you have a backup first. - Re-create the database if recovery is not possible. As a last resort, drop the database with
DROP DATABASE [YourDatabase];and restore it from backup. This removes all mirroring metadata along with the database. All data in the dropped database is lost, so verify the backup before running this. - Verify the fix. Re-run the query from step 1. The
mirroring_state_descshould returnNULLor0(no mirroring), and the database should be online and usable. Then run a simpleSELECTagainst a table to confirm normal access.
Common Mistakes
- Running
SET PARTNER OFFon the wrong instance. The command must be run on the principal first; running it only on the mirror leaves the principal metadata intact. - Dropping the mirroring endpoint while another database still uses it, which breaks mirroring for that database.
- Restoring with
WITH RECOVERYwithout a current backup, which overwrites data that may still be needed. - Assuming error 956 is a connectivity issue. It is a metadata issue, so restarting services or checking firewall rules will not clear it.
- Forgetting that labels in SSMS and error text can differ slightly by SQL Server version and language, so match on the error number and the database state rather than on exact wording.
Tips
- Record the old mirroring configuration (partner names, endpoint names, safety mode) before removing it, in case you need to rebuild the session.
- Use
sys.database_mirroringto inspect mirroring metadata per database:SELECT * FROM sys.database_mirroring WHERE database_id = DB_ID('YourDatabase');. - If you plan to re-establish mirroring, remove the old session cleanly on both sides before configuring the new one.
- Keep the principal and mirror on the same SQL Server major version when rebuilding, since mirroring requires compatible versions.
Troubleshooting
If ALTER DATABASE ... SET PARTNER OFF returns an error saying the database is not configured for mirroring, check sys.database_mirroring to confirm the actual state. If the database remains in RESTORING after the command, it is waiting on a restore or mirroring completion and must be recovered with WITH RECOVERY from a backup. If the error persists after all steps, confirm you are connected to the correct instance and database name, and check that no other session or job is holding the database in a mirroring-related state. When the mirror instance is permanently gone, remove the endpoint and metadata on the surviving instance only, then rebuild mirroring from scratch if required.
Frequently Asked Questions
What causes SQL Server error 956?
The database still has mirroring metadata from a previous session, often because the mirror was removed without running SET PARTNER OFF on the principal.
Can I clear error 956 without dropping the database?
Yes. Running ALTER DATABASE [YourDatabase] SET PARTNER OFF; on the principal usually removes the metadata without dropping the database.
Does error 956 mean my data is lost?
No. It is a configuration state, not data corruption. The database contents remain until you choose to restore over or drop the database.
What if the mirror server no longer exists?
Remove the partner on the principal, drop the unused mirroring endpoint, and if the database is stuck in RESTORING, restore it with WITH RECOVERY from a backup.
Will removing mirroring affect other databases?
Only if you drop a shared mirroring endpoint that other databases use. Check sys.database_mirroring_endpoints before dropping anything.
How do I confirm mirroring is fully removed?
Query sys.database_mirroring for the database; the mirroring state should show no partner and the database should be online.