
In this exercise, we will be using the Microsoft SQL Server Management Studio to kill the session in SQL Server database. There are 2 options, killing individual session or kill all the sessions together! That’s very cruel 🙂
Kill Individual Session
Execute command sp_who2 to determine the session and which user is currently logged.

Use kill [SPID] to kill the session.
kill SPID
Kill All Sessions
- Option 1
SELECT 'KILL ' + CAST(session_id AS VARCHAR(10))
FROM sys.dm_exec_sessions
WHERE is_user_process = 1
AND database_id = DB_ID('DATABASE_SID');
- Option 2
ALTER database [DATABASE-SID] SET SINGLE_USER with ROLLBACK IMMEDIATE;


