Home » Reply » Reply To: How can I get the query history in SQL Server?

Reply To: How can I get the query history in SQL Server?

Stephen West ~ Modified: November 2nd, 2015 ~ ~ 1 Minute Reading

Home Forums How can I get the query history in SQL Server? Reply To: How can I get the query history in SQL Server?

#879 Score: 0
Stephen West
Moderator
4 pts

Run this:

SELECT  d.plan_handle ,
        d.sql_handle ,
        e.text

FROM    sys.dm_exec_query_stats d
        CROSS APPLY sys.dm_exec_sql_text(d.plan_handle) AS e

And filter output with
WHERE text like '%something%'