To judge that a blockage occurs on a table.

Source: Internet
Author: User

1. Use sp_lock to see if the output information LockType contains-BLK characters, indicating that the lock on the page table_id the current table is blocking other processes
2. By viewing master. Syslocks system table
Cases
ID dbid page Type SPID class FID context row loid
----------- ------ ----------- ------ ------ -----
512004855 6 0 3 Non Cursor Lock 0 0 0 26
512004855 6 0 4 Non Cursor Lock 0 0 0 24
512004855 6 0 3 Non Cursor Lock 0 0 0 20
512004855 6 793 261 Non Cursor lock 0 8 0 26 The current blocking and blocked processes are known from the SPID, and the types of locks are available from the Type field, as shown in the following table:
1 0x1 table lock
2 0x2 Shared table lock
3 0x3 Exclusive Intent Lock
4 0x4 Shared Intent lock
5 0x5 Exclusive page lock
6 0x6 Shared Page lock
7 0x7 Update page lock
8 0x8 Row Lock
9 0x9 shared row lock
0xA Update row lock
0xB Share Next Key lock
256 0x100 Lock is blocking another process
0X200 Request Lock

So you can get blocking table information from the following query
Select B.name as dbname,a.id as table_id,page,spid from syslocks a,sysdatabases b
where b.dbid = A.dbid
and A.type & 256 = 256

You can also write a stored procedure, but be sure to do it in master.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.