sql >> Database >  >> RDS >> Sqlserver

SQL-query om de impasses in SQL SERVER 2008 te krijgen

U kunt een deadlock graph . gebruiken en verzamel de informatie die u nodig heeft uit het logbestand.

De enige andere manier die ik zou kunnen voorstellen, is door de informatie te graven met behulp van EXEC SP_LOCK (Binnenkort verouderd), EXEC SP_WHO2 of de sys.dm_tran_locks tafel.

SELECT  L.request_session_id AS SPID, 
    DB_NAME(L.resource_database_id) AS DatabaseName,
    O.Name AS LockedObjectName, 
    P.object_id AS LockedObjectId, 
    L.resource_type AS LockedResource, 
    L.request_mode AS LockType,
    ST.text AS SqlStatementText,        
    ES.login_name AS LoginName,
    ES.host_name AS HostName,
    TST.is_user_transaction as IsUserTransaction,
    AT.name as TransactionName,
    CN.auth_scheme as AuthenticationMethod
FROM    sys.dm_tran_locks L
    JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id
    JOIN sys.objects O ON O.object_id = P.object_id
    JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id
    JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id
    JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id
    JOIN sys.dm_exec_connections CN ON CN.session_id = ES.session_id
    CROSS APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) AS ST
WHERE   resource_database_id = db_id()
ORDER BY L.request_session_id

http://www.sqlmag .com/article/sql-server-profiler/gathering-deadlock-information-with-deadlock-graph

http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx



  1. Krijg alleen datum zonder tijd in Oracle

  2. Rails-rapporten kunnen geen kolom vinden die er is

  3. ExecuteBatch-methode retourneert array met waarde -2 in java

  4. MySQL Toon tabelstatus, automatische verhoging is niet correct