SQL Server queries blocked script for query

Source: Internet
Author: User

Original link: http://blog.sqlauthority.com/2010/10/06/ sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/

SELECT
Db.name DBName,
TL.REQUEST_SESSION_ID,
WT.BLOCKING_SESSION_ID,
object_name (p.object_id) Blockedobjectname,
Tl.resource_type,
H1. TEXT as Requestingtext,
H2. TEXT as Blockingtest,
Tl.request_mode
From Sys.dm_tran_locks as TL
INNER JOIN sys.databases db on db.database_id = tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks as wt on tl.lock_owner_address = Wt.resource_address
INNER JOIN sys.partitions as P on p.hobt_id = tl.resource_associated_entity_id
INNER JOIN sys.dm_exec_connections ec1 on ec1.session_id = tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 on ec2.session_id = wt.blocking_session_id
Cross APPLY Sys.dm_exec_sql_text (ec1.most_recent_sql_handle) as H1
Cross APPLY Sys.dm_exec_sql_text (Ec2.most_recent_sql_handle) as H2
GO

Method 2): Http://blog.wsol.com/sql-server-locks-blocked-processes-and-two-easy-ways-to-find-them

SQL Server queries blocked script for query

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.