SQL Server - Exclusive access could not be obtained because the database is in use

Frank Martin 411 Reputation points

Took backup of database from SQL Server 2008 R2 Enterprise and trying to restore it on a database on SQL Server 2019 Enterprise but getting error:

Exclusive access could not be obtained because the database is in use

I took destination database offline and then tried to restore but no luck. Restarted SQL Server service but no luck. Close existing connections to destination database is checked under Options but no luck (screenshot attached). There is enough disk space available.

Is the error coming due to version difference? If yes, then how to restore database from 2008 R2 to 2019?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,175 questions
No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 72,891 Reputation points MVP

    No, this has nothing to do with the version difference. The issue is exactly what the error message says: there are one or more processes active in this database. Well, active and active... If you have a query window open with this database as the current database that counts. Or you could have a node open in the database in Object Explorer. SQL Server don't want to make the decision to pull the rug for these processes itself, but if you know that it is OK, you can do this;

    First, use the Script button on the top of the dialogue to script the RESTORE statement to a new query window. Then above the RESTORE command, add:

       USE db_to_restore  
       USE tempdb  
       And please bear in mind that the current database will be entirely overwritten, so be careful!
    1 person found this answer helpful.
    No comments

0 additional answers

Sort by: Oldest