Friday, 7 February 2020

Currently All running queries in SQL Server

In this article, I am explaining how to find which SQL queries are being run on an SQL Server.

Using the below query, we can get list the queries running on SQL Server


SELECT b.TEXT,
a.session_id,
a.status,
a.command,
a.cpu_time,
a.total_elapsed_time
FROM sys.dm_exec_requests a
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS b

By using above query, we can find a list of queries. If we want to kill any query. We can use below command-


KILL session_id




No comments:

Post a Comment