February 5, 2009 at 8:04 am
Hello,
i read this so many times but keep getting confused between blocking and locking..now when i run sp_who2 i see some process id in the "blk" column...now does it mean that the process id in "blk" column is being locked?..when i run sp_lock..i see some information on the resources..from my understanding locks have to occur on resources..but when more than one lock occurs on the same resource then it is called block....there are tons of ways to find the block..but can anyone give me the most effecient way..this is how i plan to approach for determing blocks..
i)run sp_who2
ii)then run dashboard reports for locks( will this give which query is creating lock?)
i do not want to use profiler....suggestions will be appreciated..thansk..
February 5, 2009 at 8:22 am
A block occurs when a resource has been locked by an process and another process with an incompatible lock type attempt to acquire a lock on the same resource. Here is the BOL article that has a the Lock Compatability Matrix.
This article includes code (near the bottom) that will show blocks using the DMV's which are the recommended way to find locking\blocking issues in 2005 and newer.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
February 5, 2009 at 8:26 am
sp_who2 returns
SPID --> which is the process under consideration
BLK --> if it has a value represents the SPID of the blocking process
Ex. SPID =10 BLK=51 --> Process 10 is being blocked by process 51
sp_lock return all process request or in lock states unless the status is grant state.
-- Returns information about currently active lock manager resources.
select * from sys.dm_tran_locks
---- [font="Tahoma"]Live and Let Live![/font] ----
February 6, 2009 at 9:14 am
thanks...it helps..
September 5, 2012 at 2:29 pm
Very helpful with the procedure posted and explaining blk. Thanks!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply