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

Advertisements

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: