Monday 14 September 2015

Last Executed Sql Queries

To day I write a sql query  which is more then 100 lines.But without saving the query I cancel the query window. Now write the sql again boaring work.

After searching in google I find the query. This will display the list of all query executebin sql server recently.

from here I copy my sql and I have save the time for re-writing the sql.

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

No comments:

Post a Comment