3

Possible Duplicate:
How to see query history in SQL Server Management Studio

I want somehow to get the history of the executed queries on SQL Server 2008 R2. Let's say I run the query:

DELETE FROM TABLE

Is it logged somewhere? Can I see the queries that were executed on the server?

I want to check if a stored procedure or any other automated task was executed at a specific time.

Community
  • 1
  • 1
chaliasos
  • 9,659
  • 7
  • 50
  • 87

1 Answers1

3

Will this help?

SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC

and as pointed by anio How to see query history in SQL Server Management Studio

Community
  • 1
  • 1
Niladri Biswas
  • 4,153
  • 2
  • 17
  • 24