When restoring a SQL server database, you may get the following error:
Restore failed for server. Exclusive access could not be obtained because the database is in use. RESTORE DATABASE is terminating abnormally (MICROSOFT SQL Server, Error: 3101)
This error occurs because the database you are trying to restore is in use. Ie: Someone is running a query against it. The easiest way to fix this is to:
- Right click the server in SQL Server Management Console and click Activity Monitor.
- Click on Processes.
- Right click all processes running against the database you are trying to restore and click Kill Process.
If you are using an older version of SQL, you won’t have the Activity Monitor so you will have to detach the SQL database and check Drop Connections to close any existing connections before restoring.
You should then be able to restore the SQL database as it will no longer be in use.