Is there any script to get the output just like Activity Monitor?
Or
Which DMV's can I use to get the output as Activity Monitor displays on the screen?
It should be able to display the stored procedure name as well as the statement from the stored procedure which is currently running and the bloking related info as well.
Best Answer
I have modified the given script as follows. You can play the activity monitor on one side and this script in another window and verify the output.
You can also view the currently running expensive queries by using this script and for that just need to do ORDER BY [Total CPU (ms)] desc.
This script will display the following things:
You can also add or remove the columns whichever you need .
I have commented out some columns in the query, like: --[Open Transactions Count] = ISNULL(r.open_transaction_count,0), --[Login Time] = s.login_time, --[Last Request Start Time] = s.last_request_start_time, So if you want can also add or remove the columns as per your requirement and you can also filter out the data DatabaseName wise. I hope this script will help many of us.