T-SQL: Recently Executed Query

Posted by Fenil Desai | 1:02 AM | View Comments

I am a regular reader of Pinal Dave's blog SqlAuthority. I always found something new in his blog to work with SQL Server. Here is something I would like to share: Get the recent executed SQL Queries from SQL Server.

1.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

Posted via email from fenildesai's posterous

Share Related Posts with Thumbnails
blog comments powered by Disqus