How to view database history query records in SQL query logs

Source: Internet
Author: User

All right, go to the database log to search for it and use the time and keyword for batch configuration .. You can use all that you can think.

First, assume that you have executed it. No? Okay, either it's too simple, or you're too simple ..
Copy codeThe Code is as follows:
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) + 1
) AS statement_text,
-- Execution text
ST. text,
-- Execution plan
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-10-20 16:00:00 'AND '2017-10-20 17:00:00'
And st. text LIKE '%'
ORDER
QS. creation_time DESC

The cross apply and outer apply join statements added by SQL Server 2005 are used to join Table value functions (functions that return the table result set ), more importantly, the parameter of this function is a field in another table.

[SQL Server] CROSS APPLY and OUTER APPLY

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.