Labels

Last Queries Executed On SQL Server




/*******Last 30 query Executed on sql server******************/
SELECT Top 30
    a.last_execution_time AS [Time],
    b.TEXT AS [Query] ,
    a.total_logical_reads ,
    a.total_logical_writes ,
    a.total_elapsed_time,
    db_name(b.dbid)
FROM sys.dm_exec_query_stats AS a
CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) AS b
ORDER BY a.last_execution_time DESC


 /*******Last 30 query Executed on sql server in database******************/
SELECT Top 30
    a.last_execution_time AS [Time],
    b.TEXT AS [Query] ,
    a.total_logical_reads ,
    a.total_logical_writes ,
    a.total_elapsed_time,
    db_name(b.dbid)
FROM sys.dm_exec_query_stats AS a
CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) AS b
where b.dbid = 4 -- Mention Dbid for specific databaseORDER BY a.last_execution_time DESC

No comments:
Write comments

Please do not enter spam links

Services

More Services