Are there any good open source or otherwise free MS SQL Server transaction blocking monitor tools?
One that would detect a blocking transaction that lasts longer than X and then email an alert somewhere would be ideal.
Simple for one server.
For MS SQL Express 2008 specifically but should apply to all really, or all recent.
Yes, actually SQL Server comes with such an option out-of-the box, but very few know about it and even fewer know how to use it. It is called the
blocked process threshold:Once this option is enabled the system will generate a profiler event of the Blocked Process Report Event Class. The next piece of the puzzle is that this (as well as many more) Profiler event can be captured using DDL Event Notifications. Here is a practical example:
now, on a different session, runa query that blocks on the uncommitted transaction started above:
And sure enough, in 10 seconds (our configured threshold) we get a notification:
You can see the last executed statement by the blocker, the current executing statement from the blocked, along with wait times and a lot more.
Wiring up the event notification to activate a procedure that sends mail using
sp_send_db_mailis left as an exercise to the reader. And yes, everything mentioned above is available in Express Edition.