View Last Excuted Quries in Sql Server
SELECT DEQS.LAST_EXECUTION_TIME AS [TIME] ,SUBSTRING(DEST.TEXT,(DEQS.STATEMENT_START_OFFSET/2)+1 ,((CASE DEQS.STATEMENT_END_OFFSET WHEN -1 THEN DATALENGTH(DEST.TEXT)ELSE DEQS.STATEMENT_END_OFFSET END - DEQS.STATEMENT_START_OFFSET)/2) + 1) AS STATEMENT_TEXT ,DEST.* 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