Karthick P.K on SQL Server

How to get SQL Text and Query Plan for statements which are executing now

Posted by Karthick P.K on February 1, 2010

SELECT getdate() as "RunTime", st.text as batch,
SUBSTRING(st.text,statement_start_offset / 2+1 , 
( (CASE WHEN a.statement_end_offset = -1 
THEN (LEN(CONVERT(nvarchar(max),st.text)) * 2) 
ELSE a.statement_end_offset END)  - a.statement_start_offset) / 2+1)  as current_statement
,qp.query_plan, a.* FROM sys.dm_exec_requests a CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) as st CROSS APPLY sys.dm_exec_query_plan(a.plan_handle) as qp 
order by CPU_time desc


If you liked this post, do like us on Facebook at and join our Facebook group!/groups/454762937884205/

Thank you,

Karthick P.K |My Facebook Page |My Site| Blog space| Twitter

7 Responses to “How to get SQL Text and Query Plan for statements which are executing now”

  1. Hey there are using WordPress for your blog platform?

    I’m new to the blog world but I’m trying to get started and set up my own.
    Do you need any html coding expertise to make your own blog?
    Any help would be really appreciated!

  2. Excellent happy synthetic eyesight just for fine detail and can foresee issues prior to they will happen.

  3. Mix – Zing is available in a free version that includes ads and a
    pay version that makes the lock-screen widget available.
    MP3tunes Locker, MP3 Music Download Advance, Music Box, and Music Junk are four more music apps designed for Android.

    This is typical of positions that have a lot of flaws in pawn structure, which
    is why you should avoid having these weaknesses in your own games.

  4. […] How to get SQL Text and Query Plan for statements which are executing now […]

  5. If your preferred fruit isn’t in season, use a package of frozen fruit with its syrup.
    Ways to attain the best advantages from
    your healthy and balanced smoothie recipes is always to look at the proper mix
    of fruit and veggies. cup frozen strawberries, and one scoop vanilla
    protein powder in a blender and blend until smooth and

  6. I believe what you said made a lot of sense.
    However, what about this? what if you added a little content?
    I mean, I don’t wish to tell you how to run your blog, however suppose you added a post title that grabbed
    people’s attention? I mean How to get SQL Text and Query Plan for statements
    which are executing now MSSQLWIKI is kinda plain. You might peek at
    Yahoo’s home page and watch how they create news headlines to grab viewers
    interested. You might try adding a video or a picture or two to grab readers excited about what you’ve written.
    Just my opinion, it would make your website a little livelier.

  7. compare said

    Qualіty posts is the secret to invite the users to pay a quick visit
    the sіte, that’s what tһis web site іs providіng.

Leave a Reply to reputable credit card debt relief companies reputable credit card debt settlement companies request a credit limit increase chase request a credit limit increase chase freedom request a credit line increase chase request a credit line increase chase credi Cancel reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: