Thursday, September 14, 2017

Get Last executed Query in SQL Server

SELECT
    equery.last_execution_time AS [Time],
    esql.TEXT AS [Query]
 FROM
    sys.dm_exec_query_stats AS equery
    CROSS APPLY sys.dm_exec_sql_text(equery.sql_handle) AS esql
WHERE esql.dbid = DB_ID('DatabasName')
ORDER BY
    equery.last_execution_time DESC

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...