mssql 查询数据库脚本执行日志
select * from (SELECT
QS.creation_time as [创建时间],
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 [sql脚本],
ST.text as [执行计划],
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
--ORDER BY
--QS.creation_time DESC
) aa where 创建时间 >= '2020-09-21 00:00:01' and 创建时间 <='2020-09-21 23:00:01'
and sql脚本 like '%v_pre_cufullmooninfo%'
and sql脚本 like '%8000%'
好不容易活着