Blocked and blocking users

  • Does any one have a way (script stored procedure) to show who is holding and lock and who is being blocked and for how long.It would be great to be able to have a stored procedure return this information

    TIA

  • Here's a view I use.  I suppose you could turn it into a stored procedure.

    create view vw_BLOCKERS

    AS

    SELECT * FROM MASTER..SYSPROCESSES WHERE BLOCKED <> 0 OR

    SPID IN( SELECT BLOCKED FROM MASTER..SYSPROCESSES WHERE BLOCKED<>0)

    Tom

  • Your view will select sessions that are blocked...

    The question seemed to be asking for a listing of those who are blocked and those who are  causing the blocking

     

     

     

     

  • My view selects both.  It grabs the blocking spid with the or clause.

    SELECT BLOCKED FROM MASTER..SYSPROCESSES WHERE BLOCKED<>0

    The blocked column is the blocking spid.  Test it, it works like a charm.

    Thanks

    Tom

  • I like to use sp_who2 - get most of the information I need from that.

  • theres a bunch of useful things in the scripts --> lock and connection management section. sp_what, sp_who3 are good places to start. they arent hard to mod to get you exactly what you need.

     

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply