Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee

Wednesday, June 3, 2009

How to Find Recently Executed Queries In SQL Server [SQL Server 2005]

Today we came across a situation which required to find out recently executed queries to analyse the modifications carried out on a database server.

Here is the query which we used to find out the recently executed queries along with the date and time at which they were executed

SELECT

DMExQryStats.last_execution_time AS [Executed At],

DMExSQLTxt.text AS [Query]

FROM

sys.dm_exec_query_stats AS DMExQryStats

CROSS APPLY

sys.dm_exec_sql_text(DMExQryStats.sql_handle) AS DMExSQLTxt

ORDER BY

DMExQryStats.last_execution_time DESC

Hope this will be useful to you also.

No comments:

Post a Comment