Query SQL records executed by SQL Server

Source: Internet
Author: User
SELECTTOP1000 -- create time QS. creation_time, -- query statement SUBSTRING (ST. text, (QS. statement_start_offset2) + 1, (CASEQS. statement_end_offsetWHEN-1THENDATALENGTH (st. text) ELSEQS. statement_end_offsetEND

Select top 1000 -- Creation Time QS. creation_time, -- query statement SUBSTRING (ST. text, (QS. statement_start_offset/2) + 1, (case qs. statement_end_offset WHEN-1 then datalength (st. text) else qs. statement_end_offset END-QS. statement_start_offset)/2) +

Select top 1000
-- Creation Time
QS. creation_time,
--QueryStatement
SUBSTRING (ST. text, (QS. statement_start_offset/2) + 1,
(Case qs. statement_end_offset WHEN-1 then datalength (st. text)
Else qs. statement_end_offset END-QS. statement_start_offset)/2) + 1
) AS statement_text,
--RunText
ST. text,
--RunPlan
QS. total_worker_time,
QS. last_worker_time,
QS. max_worker_time,
QS. min_worker_time
FROM
Sys. dm_exec_query_stats QS
-- Keyword
CROSS APPLY
Sys. dm_exec_ SQL _text (QS. SQL _handle) ST
WHERE
QS. creation_time BETWEEN '2017-12-03 09:00:00 'AND '2017-12-03 11:00:00'
-- And st. text LIKE '%'
ORDER
QS. creation_time DESC


Select top 1000
-- Creation Time
QS. creation_time,
--RunText
ST. text
FROM
Sys. dm_exec_query_stats QS
-- Keyword
CROSS APPLY
Sys. dm_exec_ SQL _text (QS. SQL _handle) ST
WHERE
QS. creation_time BETWEEN '2017-12-03 09:00:00 'AND '2017-12-03 11:00:00'
And st. text not like '% SELECT * FROM T_LOCATIONINFO where strcliplogicid in (%'
ORDER
QS. creation_time DESC

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.