Even though nothing is using it I am unable to detach a database because it is use.

Cannot detach the database 'DEMO' because it is currently in use.

I have tried rebooting and get the same message.

link|improve this question
feedback

3 Answers

up vote 7 down vote accepted
--Kick all users off of the database NOW
ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--Kick all but after 60 seconds
ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK AFTER 60 SECONDS

--restore connection to users
ALTER DATABASE YourDatabase SET MULTI_USER
link|improve this answer
feedback

Have you tried checking the "Drop Connections" box when you detach it?

link|improve this answer
I was hoping more for a query related solution. Server Management Studio Express very often causes my machine to blue screen. So I'm using a tool that just sends queries to the server. – Jack B Nimble Oct 20 '09 at 17:54
A blue screen is usually related to hardware or OS-level problems, not to some very specific application such as a database management tool. I can't imagine why this particular program makes your machine crash, but this is definitely a symptom of some underlying serious problem. – Massimo Oct 20 '09 at 18:53
It is some combination of Visual Studio and Server Management Studio Express, because I have seen the behavior on 3 different workstations. It might be from running multiple versions of Visual Studio at once, I know this causes bizarre behavior in IE7 when using tabs. – Jack B Nimble Oct 28 '09 at 18:30
feedback

This command should drop all connections, then allow you to detach.

ALTER DATABASE SET SINGLE_USER WITH ROLLBACK_IMMEDIATE

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.