Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Kristian Ask,
This script will use the standard sp_who2 to fill a temporary table with currently run processes rather than copying the code from that sp_who2 to my own.
The difference from others are that it is also getting the command being run by the process. Normally I know what database is using the resources but not the actual query being run.
Parameters to use are:
@SPID - process to show
@DBName - processes for this db only
@running - 1 for currently running processes, 0 for not running processes and null for all
@blocked - 1 for blocked processes, 0 for non-blocked processes and null for all
@eventinfo - like search on the SQL command being run
Feel free to use it...
Blocked and Blocking process Help
Find Percentage of blocked processes
Where to check for blocked processes in SQL Server ??
When excessive blocking occurs in SQL, performance degrades. Learn how to use the Blocked Process R...