Listare queriuri active pe o baza de date MSSQL

Configurare noua (How To)

Situatie

Procedura de mai jos listeaza toate queriurile ce sunt in statusul running pe o baza de date MSSQL, cu exceptia query-ului de fata.

Solutie

create procedure ListRunningQueries

as

select text,
SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END – qs.statement_start_offset)/2) + 1) AS statement_text,
*
from sys.dm_exec_requests qs
cross apply sys.dm_exec_sql_text(sql_handle) st
cross apply sys.dm_exec_query_plan(plan_handle)
where session_id <> @@spid

Tip solutie

Permanent
Etichetare:

Voteaza

(12 din 26 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?