Thursday, June 16, 2011

How to Kill open connections to a Database

I came across a scenario when I wanted to restore a Database. However I was getting an error saying the databse is already in use. I needed to find who was connected to the databse and kill that connection.
So I first ran the command exec sp_who
This gave me the spid of the connection.
Then I ran the commad kill _spid to kill this connection.

No comments:

Post a Comment