Wednesday, March 21, 2012

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

I have a test database that is automatically restored from the live database each day at 2:30AM. I recently started receiving this message:

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

and the restore is not able to occur.

Any ideas on how I can prevent this from happening?

You can't restore a db when it is in use, meaning that there are connections open to the database. Somehow, somewhere, connections are being left open to your database. Before you leave for the day, run the following:

exec sp_who

This will tell you who (username and machine name) has an open connection to the database.

No comments:

Post a Comment