Backup & Restore

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

I’ve got an email from a friend. He was made backup of a database, and restore that backup file to another new database but he got error “Exclusive access could not be obtained because the database is in use”. I’m trying by myself to restore a database in my machine with the same scenario and got the full error as the following picture :

error-restoring-exclusive-access

Once I look at this error, I just know that his new database was in use. First thing i have to do is find out which process or session that using his database using sp_who2 stored procedure, and kill that process.

sp_who2

connection-to-database

From sp_who2 stored procedure result, I’ve found out that a connection with SPID 58 has using my database. Just kill that process and try again to restore that database and the error has gone.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s