Uncategorized

Show last executed query SQL Server – Disected

I found this online, without explanation so I will dissect the query and explain what is happening.

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

This beautifully crafter query will show us last few queries executed on they db, very usefull for seeing what is Hibernate generating for us.

One thought on “Show last executed query SQL Server – Disected

  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

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *