SQL Server executed statement query

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.