DBA Sensation

December 10, 2008

Find Long running queries in SQL2005

Filed under: 3. MS SQL Server — zhefeng @ 2:27 pm

The following query shows you the long running queries in the database by combination of few dynamic management views. It’s quite useful to get the “bottleneck” on-the-fly when your system is super busy.

Select dmText.text as 'Executed Query',dmStats.last_execution_time as 'Last Executed Time', dmstats.*
from
sys.dm_exec_query_stats as dmStats
Cross apply
sys.dm_exec_sql_text(dmStats.sql_handle) as dmText
Order By
total_elapsed_time desc,
dmStats.last_execution_time desc

1 Comment »

  1. What’s up, this weekend iis good for me, because this moment i am reading
    this impressive informative post here at my house.

    Comment by casino — July 20, 2014 @ 10:14 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.