select total_worker_time/execution_count/1000 as AverageCPUTime, total_elapsed_time/execution_count/1000 as AvgDuration, st.text from sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text(qs.sql_handle) st where (total_worker_time/execution_count) > 10000000 -- 10 seconds in microseconds order by total_worker_time/execution_count
We walk in the dark places no others will enterWe stand on the bridge and no one may pass
SELECT sql_handle, plan_handle, execution_countFROM sys.dm_exec_query_stats AS qsCROSS APPLY sys.dm_exec_sql_text (qs.plan_handle) AS sql