代码改变世界

【SQLServer】死锁查看

2022-07-30 22:38  abce  阅读(279)  评论(0编辑  收藏  举报
SELECT
    session_id,
    start_time, 
    [status],
    command,
    blocking_session_id,
    wait_type,
    wait_time,
    open_transaction_count,
    transaction_id,
    total_elapsed_time,
    Definition = CAST(text AS VARCHAR(MAX))
FROM
    SYS.DM_EXEC_REQUESTS
    CROSS APPLY sys.dm_exec_sql_text(sql_handle) 
WHERE blocking_session_id != 0

  

https://www.mytecbits.com/microsoft/sql-server/t-sql-query-to-find-deadlocks