SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sp_who2 - sp_lock


sp_who2 - sp_lock

Author
Message
curious_sqldba
curious_sqldba
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 7024 Visits: 3696
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..
Jack Corbett
  Jack Corbett
SSC-Forever
SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)

Group: General Forum Members
Points: 42485 Visits: 14925
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
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

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
jagadishrashmi
jagadishrashmi
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 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! ----
curious_sqldba
curious_sqldba
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 7024 Visits: 3696
thanks...it helps..
njeschel08
njeschel08
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 5
Very helpful with the procedure posted and explaining blk. Thanks!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search