SELECT TOP 30000Total_worker_time/ + as [Total CPU time consumed (ms)], Execution_count[Number of runs], Qs.total_worker_time/Qs.execution_count/ + as [average CPU time consumed (ms)], Last_execution_time as [Last Execution Time], Min_worker_time/ + as [Minimum Execution time (MS)], Max_worker_time/ + as [Maximum Execution time (MS)], SUBSTRING(QT.text, Qs.statement_start_offset/2+1, ( Case whenQs.statement_end_offset= -1 Then datalength(QT.text) ELSEQs.statement_end_offsetEND -Qs.statement_start_offset)/2 + 1) as [syntax for using CPUs]Qt.text [Full Syntax], Qt.dbid, dbname=db_name(Qt.dbid), Qt.objectid,object_name(qt.objectid,qt.dbid) ObjectName fromSys.dm_exec_query_stats QS with(NOLOCK) CrossApply Sys.dm_exec_sql_text (Qs.sql_handle) asQTWHEREExecution_count>1 andQs.creation_timebetween '2017-11-13 20:10:00' and '2017-11-13 20:15:00' ORDER by(Qs.total_worker_time/Qs.execution_count/ +)DESC
SELECT TOP +ST.text as 'The SQL statement executed', Qs.execution_count as 'Number of executions', Qs.total_elapsed_time as 'Time Consuming', Qs.total_logical_reads as 'number of logical reads', Qs.total_logical_writes as 'number of logical writes', Qs.total_physical_reads as 'number of physical reads', Qs.creation_time as 'Execution Time', QS.* fromsys.dm_exec_query_stats QS CrossAPPLY sys.dm_exec_sql_text (qs.sql_handle) STWHEREQs.creation_timebetween '2015-08-01 00:00:00' and '2015-09-02 11:00:00' ORDER byQs.total_elapsed_timeDESC
SQL Server executed statement query