MS SQL Server - Finding Running Server Processes and Killing the Processes which are Currently in a Blocked State
It is sometimes needed to see the running server processes and if necessary kill the ones who are in a blocked state. In order to do that you can use the following T-SQL scripts;
This will return you the active processes and simply using the session_id value, you can kill the processes.
This will return you the active processes and simply using the session_id value, you can kill the processes.
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests
req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
KILL [session_id]
GO
Also you can run the following script and check the BlkBy field for the SPIDs that are blocking other processes and then you can kill them.
EXEC sp_who2
GO
KILL 53
GO
Once you run the "KILL" command, you can run the following command to check the results again;
EXEC sp_who2
GO
Comments
Post a Comment