Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

My Experiments with SQLServer
Browse by Tags · View All
SQLServer 126
SQLServer 2008 R2 91
SQLServer 2008 86
SQLServer 2005 82
SQL 60
Database 59
Sql And Me 57
Tips & Tricks 28
SQL Server 27
SQL FAQ 26

Archive · View All
May 2011 25
June 2011 21
July 2011 21
August 2011 19
April 2011 16
January 2013 4
May 2012 3
April 2012 3
October 2011 3
February 2013 2

Vishal Gajjar's Blog

SQL Server – Finding currently running queries

Aug 10 2011 12:23AM by Vishal Gajjar   

You can use sys.dm_exec_requests DMV to list all requests. This view also contains a hash map of the SQL text – sql_handle, which can be passed to DMF sys.dm_exec_sql_text to get the query text:

SELECT      REQUEST.session_id, REQUEST.start_time, QUERY.text
FROM        sys.dm_exec_requests REQUEST
CROSS APPLY
            sys.dm_exec_sql_text(REQUEST.sql_handle) QUERY

Result Set:

session_id start_time               text
———- ————             ——————
54         2011-08-10 20:28:17.840  SELECT REQUEST.session_id, REQUEST.start_time,
                      QUERY.text
                      FROM   sys.dm_exec_requests REQUEST
                      CROSS APPLY
                                    sys.dm_exec_sql_text(REQUEST.sql_handle) QUERY
56         2011-08-10 20:27:02.380  USE SqlAndMe SELECT ProductID, Name
                                                               FROM   ProductList
 
(2 row(s) affected)

In case you are trying to find the query which is causing blocking, you can find the blocking session id by using sp_who or sp_who3.

Once you locate the blocking session id, it can be used to filter above results:

SELECT      REQUEST.session_id, REQUEST.start_time, QUERY.text
FROM        sys.dm_exec_requests REQUEST
CROSS APPLY
            sys.dm_exec_sql_text(REQUEST.sql_handle) QUERY
WHERE REQUEST.session_id = 58

Result Set:

session_id start_time               text
———- ————             ——————
58         2011-08-10 20:39:17.773  UPDATE ProductList  SET  Name = 'Bearing Ball'
(1 row(s) affected)


Republished from Sql&Me [31 clicks].  Read the original version here [32134 clicks].

Vishal Gajjar
46 · 4% · 1276
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • Hi , I Think there is no spwho3,its spwho2 ( typo error),please check .

    commented on Nov 7 2011 11:13AM
    rajasekhar
    211 · 1% · 221

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]