What’s Running – Find All Details of Running Queries

I often see DBAs/developer struggling to find what’s wrong with query. The first step in troubleshooting queries is finding out information like batch text, query text, batch execution plan, individual statement query plan, granted_memory, request_status, wait_type, program_name, login_name, wait_resource, blocking info, Logical Reads, writes, CPU time, query_hash and query_plan_hash.

For this purpose, I have created my own TSQL code this gives all above details. In case the running session is SQL Agent job, then Program_Name column data would be shown like SQL Job = < job name >. You can find the latest modified code on my SQLDBA-SSMS-Solution GitHub repository using below URL:-

imajaydwivedi/SQLDBA-SSMS-Solution/BlitzQueries/WhatIsRunning.sql

Another way to get running session details is using Adam Mechanic’s [sp_WhoIsActive]. I have modified the latest script v11.30 to provide the job name in case the running session belongs to sql agent job. You can find the latest modified code on my SQLDBA-SSMS-Solution gitub reposity using below url:-

imajaydwivedi/SQLDBA-SSMS-Solution/BlitzQueries/who_is_active_v11_30(Modified).sql

Below is the sample screenshot:-

Friends! Please feel free to correct me by comments. If you like the article, do Like & Share. Happy Coding 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.