SQL Server: Kill your running Sessions or Change Database Mode (Multi_User to Single_User)

In this post, I am sharing scripts to kill all your running processes or sessions of SQL Server.

DBA always set time of database maintenance activities, but sometime they find few running sessions so they require to close all connections of a SQL Server Database.

Before executing this script, please take care and verify all running connections and processes otherwise this script will harm to your data.

You require this type of script very occasionally, but I am sharing here because this is also one of the important script for SQL DBA.

How to find running sessions or processes in SQL Server?

Script to find Running Process and Session in SQL Server

Command to Kill particular session_id:

Change your database mode from multi-user to single-user:

Once you change the database mode from multi-user to single-user, SQL Server immediately stops all the connections of the database. No one can connect to that database.

The DBA can perform the maintenance activity and after that, they can again change the database mode from single-user to multi-user.

To set Single User:

To set Multi User:


Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz