Hello:
Twice this week, I have gotten in trouble with SQL 2005 preventing me from
conducting different tasks because it gives me a message saying that
something is "in use".
I know about running sp_who and sp_who2, in order to track down a database
or process that is "in use". But, even with going into the Activity Monitor
afterward, it would not let me kill processes that were preventing me from
accomplishing tasks. I would right-click on a process in Activity Monitor
and nothing would happen.
One task was restoring a database. Since SQL told me that database was in
use, even though it was not, I had to have all users log out in order to
restore.
Another situation was last night, when I was trying to detach a database. I
was told that it was in use, and it was not. I had to stop and restart SQL
while in Management Studio, in order to detach.
My question is: how do you kill such "hung" processes when you cannot do so
in Activity Monitor?
SQL 2005 is very frustrating. I miss the good ole SQL 2000 days.
Thanks, for your time!!!
SQL Programmer (it's just a name)
Denny Cherry - 11 Jul 2008 21:13 GMT
You can kill processed by using the KILL command. You can see what
processes are running by looking at the sys.sysprocesses DMV.
SELECT spid
FROM sys.sysprocesses
WHERE dbid = db_id('YourDatabase')
When restoring a database, or detaching a database within the UI you
have to right click on the database which opens a session to the
database, which then causes you to lock the database and make it
unavailable for restoring to detaching.
Denny
>Hello:
>
[quoted text clipped - 24 lines]
>
>SQL Programmer (it's just a name)