SqlServer中查询操作记录的方法

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 ‘2020-11-10 00:00:00‘ AND ‘2020-11-17 00:00:00‘
-- AND ST.text NOT LIKE ‘%SELECT * FROM T_LOCATIONINFO WHERE STRCLIPLOGICID in(%‘
AND ST.text LIKE ‘%表名%‘
ORDER BY
QS.creation_time DESC

 

表名 Txj_web_user_record

时间范围:QS.creation_time BETWEEN ‘2020-11-10 00:00:00‘ AND ‘2020-11-17 00:00:00‘

 

SqlServer中查询操作记录的方法

上一篇:数据库文件托管


下一篇:MySql忘记密码