Home > Database > Mysql Tutorial > body text

查询SQLSERVER执行过的SQL记录

WBOY
Release: 2016-06-07 15:25:44
Original
2019 people have browsed it

SELECT TOP 1000 --创建时间 QS.creation_time, -- 查询 语句 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 
--创建时间 
QS.creation_time, 
--查询语句 
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, 
--执行文本 
ST.text, 
--执行计划 
QS.total_worker_time, 
QS.last_worker_time, 
QS.max_worker_time, 
QS.min_worker_time 
FROM 
sys.dm_exec_query_stats QS 
--关键字 
CROSS APPLY 
sys.dm_exec_sql_text(QS.sql_handle) ST 
WHERE 
QS.creation_time BETWEEN '2012-12-03 09:00:00' AND '2012-12-03 11:00:00' 
--AND ST.text LIKE '%%' 
ORDER BY 
QS.creation_time DESC


SELECT TOP 1000 
--创建时间 
QS.creation_time, 
--执行文本 
ST.text
FROM 
sys.dm_exec_query_stats QS 
--关键字 
CROSS APPLY 
sys.dm_exec_sql_text(QS.sql_handle) ST 
WHERE 
QS.creation_time BETWEEN '2012-12-03 09:00:00' AND '2012-12-03 11:00:00' 
AND ST.text NOT LIKE '%SELECT * FROM T_LOCATIONINFO WHERE STRCLIPLOGICID in(%' 
ORDER BY 
QS.creation_time DESC

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template