Killing Active SQL Server DB Connections


Working as developer you often have to deal with SqlServer database activities. In a development environment a very basic task is to take backup and restore the database. But sometimes if that environment is shared and multiple people connects to the DB server then performing database level operation might lead to the following error:

"Can not perform xxxxx operation because the database either is in use or you donot have permisssions".

This is because you have active connections to your database. Now to see the those active connections follow below steps-

For SqlServer 2008 R2

  1. Open SQL Server Management Studio
  2. Go to the ObjectExplorer and right-click on the connection item:

    DBconnections.gif

This will open the details in the right side window:

DBconnections1.gif

Now right-click on the process to be killed and select Kill Process.

DBconnections2.gif

For SQL Server 2005

In SQL Server 2005 you can find the activity monitor in the ObjectExplorer under the Connection –> Management –> Activity monitor:

DBconnections3.gif

Double-click and there will be a new window that will show you the current process on each database. Right-click on the desired item then select kill process.

And you're done. Now you can perform your Database level operations.

Up Next
    Ebook Download
    View all
    Learn
    View all