Saturday, November 9, 2013

Query to Check Currently running queries on Database server

If you are looking for which query executing on server you can use the following query to get the result


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


if you want to kill some long running query then you can fire following command to terminate the query execution

kill [process id]


Happy Coding.