HowTo : SQLServer 2005 : Exclusive access could not be obtained because the database is in use
by toy
“Exclusive access could not be obtained because the database is in use”
I got stuck with this error couple days, so mad. I found this solution in this topic, it works fine for me, anyway here’s the solution
When you want to restore database in SQLServer you must use ‘master’ database run command. If it work fine, so never mind, but if you got stuck in this kind of errors again. This solution may help you.
Use this sql to drop connections
ALTER DATABASE databasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE
And follow with restore sql
RESTORE DATABASE databasename FROM …
The last follow with allow connections
ALTER DATABASE databasename SET MULTI_USER
Twitter
Facebook