Saturday, April 6, 2013

Know the last executed Statement in Sql Server

Sometime to do analysis on locking, blocking, or other maintenance activities we need to get the information on last executed statements (queries) in our database.

So to get the list of executed statement you can run this query

t.TEXT QueryName,
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY last_execution_time DESC

No comments: