Close Menu



SQL SERVER script to Identify Currently Running Queries

There might be situations where u might be getting requests from users saying that the entire website is slow or the application is slow. Situations like these could be because of a slow running query where users might have an impression of the enire server being slow and u might be getting Support Tickets related to that. Well Situations like these may demand you to look into some currently running queries on the server. Sometimes these currenty running queries may be long running queries may even be the cause for a complete server slowness depending on your isolation levels.

If we could identify all the currently running queries or keep monitoring the queries wich are run we can identify a bad query and determine if that could be a bad query

In the image below shown the query is run on my personal laptop where no currently running queries are present. However when u run the same on a production machine you will get a lot of queries being displayed in the results.

Before You Proceed We recommend you to read our Disclaimer below

Please test the script on your testing or Dev (development) environment's which are expendable before executing or implementing these scripts over production or realtime environment. Also get the Aprovalfrom your DBA before executing these scripts

The information contained in this website is for general information, Educational and Practice purposes only. The information is provided by and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk.

In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website.

Through this website you are able to link to other websites which are not under the control of [business name]. We have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them.

Every effort is made to keep the website up and running smoothly. However, [business name] takes no responsibility for, and will not be liable for, the website being temporarily unavailable due to technical issues beyond our control.

r.session_id, r.status, r.start_time, r.command, s.
sys.dm_exec_requests r
APPLY sys.dm_exec_sql_text(r.sql_handle) s

you can download the Script here here