use master go declare @total bigint select @total = sum(total_worker_time) from sys.dm_exec_query_stats qs where total_worker_time > 0 -- and st.dbid is not null and datediff(mi,last_execution_time,getdate()) < @minutes_since_last select top 20 cast(total_worker_time / (@total * 0.01) as decimal(6,2)) 'percent' , (total_worker_time)/1000 as 'total worker ms' , (total_elapsed_time)/1000 as 'elapsed ms' , execution_count 'execs' , execution_count / (datediff(mi,creation_time,last_execution_time) + 1) as 'execs/min' , cast((total_worker_time+0.0)/(execution_count*1000) as decimal(10,2)) as 'avg cpu' , cast((total_elapsed_time+0.0)/(execution_count*1000) as decimal(10,2)) as 'avg dur' , case when sql_handle IS NULL then ' ' else ( substring(st.text,(qs.statement_start_offset+2)/2,(case when qs.statement_end_offset = -1 then len(convert(nvarchar(MAX),st.text))*2 else qs.statement_end_offset end - qs.statement_start_offset) /2 ) ) end as query_text , st.dbid , object_name(st.objectid) 'proc' , st.objectid as object_id , total_logical_reads as [Reads] , total_logical_reads/execution_count as [avgReads] from sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text(sql_handle) st where total_worker_time > 0 and st.dbid is not null and datediff(mi,last_execution_time,getdate()) < @minutes_since_last and execution_count > 10 --and st.objectid = 119059560 --order by total_worker_time desc