When performing a full restore over an existing database, SQL Backup sometimes reports that the database cannot be restored because it is currently in use.
This error shows not only during restore backup, but also for drop database or alter database as well.
In this situation:
- Run Delete Activity against DYNAMICS to disconnect all the connected users
- If you still getting the same error to get exclusive access of the Database, the other solution to this problem is to take the database offline prior to running the restore: this is the easiest way to kill all connections to the database.
- Before restore attempt
To get a Single User access to a database. SINGLE_USER WITH ROLLBACK IMMEDIATE command is used only one user can connect to the database at a time.
alter database DB_NAME set offline with rollback immediate;
- After restore
To give Multiple User access to a database. MULTI_USER command is used any number of users who have rights to connect to the database will be able to connect to the database.
alter database DB_NAME set online with rollback immediate;