Currently Running Queries in SQL Server

SQL Server

This Transact-SQL statement will return detailed information about what queries are running right now, including the execution plan, text of the query, user name, and the source of the query. This might be helpful in troubleshooting what is happening on your SQL Server database instance.

SELECT T.[Text] as [Query Text],  
       p.[Query_Plan] as [Query Plan],
       s.[Program_Name] as [Program Name],
       s.host_name as [Host],   
       s.client_interface_name as [Interface],   
       s.login_name as [Login Name],
       r.*
FROM   sys.dm_exec_requests r inner join sys.dm_exec_sessions S 
       ON s.session_id = r.session_id cross apply
       sys.dm_exec_sql_text(r.sql_handle) T cross apply
       sys.dm_exec_query_plan (plan_handle) P;
Advertisements

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