SQL Server sp_who2 Blocking Check

Connect to the SQL server database, run an sp_who2 command, loop through the dataset to find Blocks

I created this task to periodically check our SQL server database for datablocks caused by legacy applications.

This script will connect to the SQL server database, run an sp_who2 command, and loop through the dataset to find Blocks. Once blocks are identified, an append-log will be written. Since the database will on occasion have blocks. I am looking for the users that belong to the support-user domain, specifically that causes blocks, in a nested loop. if they are found to be causing the block, the task will email me with the appropriate information so that I can deal with the users. You can also add a function to kill the SPID of that user... which I use in another task that I have set up.

Enjoy..

Task Category:

SQL