dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
It is relatively simple to establish what has caused a deadlock in one of your database objects. All you need know is how to manipulate the built in System databases in order to get the appropriate information.
Jun 7, 2016

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Determine who and what Caused a Deadlock in one of your Database Objects

It is relatively simple to establish what has caused a deadlock in one of your database objects. All you need to do is to know how to manipulate the built in System databases in order to get the appropriate information.

The following Query:

SELECT  SysTL.request_session_id, 
    DB_NAME(SysTL.resource_database_id),
    SysO.Name, 
    SysP.object_id, 
    SysTL.resource_type, 
    SysTL.request_mode,
    SysSQLT.text,        
    SysES.login_name,
    SysES.host_name,
    SysST.is_user_transaction,
    SysAT.name,
    SysCN.auth_scheme 
FROM    sys.dm_tran_locks SysTL
    JOIN sys.partitions SysP ON SysP.hobt_id = SysTL.resource_associated_entity_id
    JOIN sys.objects SysO ON SysO.object_id = SysP.object_id
    JOIN sys.dm_exec_sessions SysES ON SysES.session_id = SysTL.request_session_id
    JOIN sys.dm_tran_session_transactions SysST ON SysES.session_id = SysST.session_id
    JOIN sys.dm_tran_active_transactions SysAT ON SysST.transaction_id = SysAT.transaction_id
    JOIN sys.dm_exec_connections SysCN ON SysCN.session_id = SysES.session_id
    CROSS APPLY sys.dm_exec_sql_text(SysCN.most_recent_sql_handle) AS SysSQLT
WHERE   resource_database_id = db_id()
ORDER BY L.request_session_id

Determines which user has caused the lock, on what object is the lock, as well as all associated transactions in the current query’s feed — even the SQL text that is busy executing

Hannes du Preez
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date