SELECT
(total_elapsed_time/execution_count)/1000 n ' Average time ms '
, total_elapsed_time/1000 n ' Total time spent MS '
, total_worker_time/1000 n ' Total CPU time MS '
, total_physical_reads n ' total physical reads '
, Total_logical_reads/execution_ Count n ' per logical read '
, total_logical_reads n ' logical read total number '
, total_logical_writes n ' logical write total number '
, execution_count n ' execution count '
, SUBSTRING (St.text, (QS.STATEMENT_START_OFFSET/2) + 1, (case statement_end_offset WHEN-1 then datalength (st.text ) ELSE Qs.statement_end_offset End-qs.statement_start_offset)/2) + 1) n ' execute statement '
, St.text
, Creation_time N ' statement compilation time '
, Last_execution_time N ' last execution time '
from Sys.dm_exec_query_stats as Qs
Cross APPLY sys.dm_exec_sql_text (qs.sql_ HANDLE) St
--where SUBSTRING (st.text
--, (QS.STATEMENT_START_OFFSET/2) + 1
--, (case statement_end_offset WHEN-1 then Datalength (st.text) ELSE qs.statement_end_offset end-qs.statement_start_offset)/2) + 1) Not like '%fetch% '
ORDER by Total_elapsed_time/execution_count DESC
SQL Server found a slow execution of the SQL