Killing Active SQL Server DB Connections

Introduction

In this article, we will learn about Killing Active DB Connections in SQL Server.

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

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

This is because you have active connections to your database. Now to see those active connections follow the 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.


Similar Articles