Monday, December 13, 2021

Historical Queries run on a SQL Server database

 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

WHERE text like '%2021-05-31%'


Source : https://dba.stackexchange.com/questions/4043/can-i-see-historical-queries-run-on-a-sql-server-database