SQL Server transactions, locks, and blocking

Source: Internet
Author: User

Check for blocking:

1. SYS. dm_tran_locks (sp_lock or syslockinfo must be used in sqlserver2000)

Code SELECT
Request_session_id AS spid,
Resource_type AS restype,
Resource_database_id AS dbid,
Resource_description AS res,
Resource_associated_entity_id AS resid,
Request_mode AS mode,
Request_status AS status
FROM sys. dm_tran_locks;

2. query SYS. dm_exec_connections to obtain conflicting connection information. query SYS. dm_exec_sessions to obtain conflicting session information. (Sp_who/sp_who2 or system table sysprocesses can be used in sqlserver2000)

Select * From SYS. dm_exec_connections
Where session_id in (53, 51 ); Select * From SYS. dm_exec_sessions
Where session_id in (53, 51 );

For details, see chapter 9th of sqlserver2005 inside-program.

Select * From SYS. dm_exec_requests
Where blocking_session_id> 0;

 

Related Article

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.