Working on a project recently where I had no access to the original code which generates some sales reports for a customer. After a little digging I found this gem of a chunk of SQL which shows you all recent SQL queries to the MSSQL server. SELECT SQLTEXT.text, STATS.last_execution_time FROM sys.dm_exec_query_stats STATS CROSS APPLY sys.dm_exec_sql_text(STATS.sql_handle) […]