notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Voir les transaction ancienne ou longues.sql

11 lines
501 B
MySQL
Raw Normal View History

2020-11-26 17:38:25 +00:00
-- 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;