SQL-SERVER Current / Active Queries
علی ذوالفقار
1399/02/30 12:54:08 (907)
use this script to get the current running sql qieries
SELECT
p.spid, p.status, p.hostname, p.loginame, p.cpu, r.start_time, t.text
FROM
sys.dm_exec_requests as r,
master.dbo.sysprocesses as p
CROSS APPLY sys.dm_exec_sql_text(p.sql_handle) t
WHERE
p.status NOT IN ('sleeping', 'background')
AND r.session_id = p.spid
we can kill each active query by pass the query spid to kill function :
kill [spid]