Today we came across a situation which required to find out recently executed queries to analyse the modifications carried out on a database server.
Here is the query which we used to find out the recently executed queries along with the date and time at which they were executed
DMExQryStats.last_execution_time AS [Executed At],
DMExSQLTxt.text AS [Query]
sys.dm_exec_query_stats AS DMExQryStats
sys.dm_exec_sql_text(DMExQryStats.sql_handle) AS DMExSQLTxt
Hope this will be useful to you also.
[end of post]