SELECT st.Text,
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
),
qp.query_plan,
qs.plan_handle,
qs.sql_handle,
DB_NAME(st.dbid) as dbname,
qs.creation_time,
qs.last_execution_time,
getdate() as currenttime,
qs.execution_count,
qs.last_worker_time,
qs.last_physical_reads,
qs.last_logical_reads,
qs.last_elapsed_time
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
OUTER APPLY sys.dm_exec_query_plan(qs.plan_handle) as qp
WHERE 1=1
and st.text like ‘%Grants_SumGrantsFromVesting%‘
order by creation_time desc
原文地址:https://www.cnblogs.com/lilongchuan/p/9395349.html
时间: 2024-10-12 05:33:52