Find Slow Long Running Queries in SQL Server
Related to:: SQL Server
This is a WIP, with some queries to identify running queries on SQL.
It is handy when we need to find some slow/long-running queries.
sp_who2
SELECT
p.spid,
p.status,
p.hostname,
p.loginame,
p.cpu,
r.start_time,
r.command,
p.program_name,
text
FROM
sys.dm_exec_requests AS r,
master.dbo.sysprocesses AS p
CROSS APPLY sys.dm_exec_sql_text (p.sql_handle)
WHERE
p.status NOT IN('sleeping', 'background')
AND r.session_id = p.spid
ORDER BY
cpu DESC