Tuesday, September 22, 2015

Exclusive access could not be obtained because the database is in use error when restoring DB

Sometimes we get this message when restoring database in SQL server. To overcome this we must restore the database using single user mode, which will automatically disconnect any others connections.

Below are the steps:
  1. Right click on your database that  you want to restore> properties > options > State > Restrict Access > select Single user (single user to cut off all the connections to the db that you are restoring)
  2. Restore your database
  3. Change the State back to Multi-User