This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one TSQL script to find top 20 Running Queries, which are utilizing more CPU time and degrade the performance of the SQL Server.
The database performance optimization is one the most important task for Database Professionals.
We have found that many times SQL Server occupying more CPU resources and at that time it is required to find which runnable query is occupying more CPU resources.
I am using sys.dm_exec_cached_plans to find CPU used by all the running queries.
SELECT TOP 20
SP.SPID AS ProcessID
,SP.CPU AS CPU
,EST.text AS QueryText
,SP.Open_tran AS IsAnyOpen_Transaction
,SP.Status AS StatusText
,SP.program_name AS ApplicationName
,SP.loginame AS LoginName
FROM sys.sysprocesses AS SP
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS EST
WHERE SP.Status = 'runnable'
ORDER BY SP.CPU DESC