Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sp_who2 - sp_lock Expand / Collapse
Author
Message
Posted Thursday, February 5, 2009 8:04 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:05 PM
Points: 1,283, Visits: 2,960
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..
Post #650894
Posted Thursday, February 5, 2009 8:22 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:47 AM
Points: 11,308, Visits: 13,096
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

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

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
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #650921
Posted Thursday, February 5, 2009 8:26 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, November 11, 2011 12:01 PM
Points: 158, Visits: 55
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


---- Live and Let Live! ----
Post #650926
Posted Friday, February 6, 2009 9:14 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:05 PM
Points: 1,283, Visits: 2,960
thanks...it helps..
Post #651782
Posted Wednesday, September 5, 2012 2:29 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 23, 2012 9:11 AM
Points: 1, Visits: 5
Very helpful with the procedure posted and explaining blk. Thanks!
Post #1354891
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse