-1

I have a need to pull all the recently executed SQL statements from SQL Server. What is the log file and location that I need to look for.

Dale K
  • 25,246
  • 15
  • 42
  • 71
uppili
  • 1
  • 1
    Does this answer your question? [How to see query history in SQL Server Management Studio](https://stackoverflow.com/questions/5299669/how-to-see-query-history-in-sql-server-management-studio) – tim Dec 08 '19 at 04:24
  • 1
    It was asked many times, Please try to search before asking. – XAMT Dec 08 '19 at 07:43

1 Answers1

1

Try This

SELECT B.TEXT AS [Query], A.execution_count [Count], A.last_execution_time AS [Time]
FROM sys.dm_exec_query_stats AS A
CROSS APPLY sys.dm_exec_sql_text(A.sql_handle) AS B
ORDER BY A.last_execution_time DESC
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115