Check which Query is currently running on SQL Server

Hi Folks,

Today I am sharing a pretty useful query often required when to many user’s are working on same server

and one query might be blocking another and we want to see which queries were the culprits,you can fire

the below and query and check the currently running queries on your server.

USE master
GO
SELECT DB_NAME(database_id) AS [Database], [text] AS [Query]
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.plan_handle) st
WHERE session_Id > 50           — Consider spids for users only, no system spids.
AND session_Id NOT IN (@@SPID)  — Don’t include request from current spid.

 

Sample output:

image

I would like to have feedback from my blog readers.

Please post your feedback, question, or comments about this article.

Advertisements

One thought on “Check which Query is currently running on SQL Server

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