notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Voir les transaction ancienne ou longues.sql
2020-11-26 18:38:25 +01:00

11 lines
501 B
SQL

-- transaction la plus ancienne dans la base contextuelle
DBCC OPENTRAN WITH TABLERESULTS
-- transaction de plus de n secondes (ici 30) par bases
SELECT DB_NAME(database_id), DATEDIFF(second, transaction_begin_time, GETDATE()) AS DURATION_SECOND, *
FROM sys.dm_tran_active_transactions AS tat
JOIN sys.dm_tran_database_transactions AS tdb
ON tat.transaction_id = tdb.transaction_id
WHERE database_id > 4
AND DATEDIFF(second, transaction_begin_time, GETDATE()) > 30;