Find the oldest open transaction (ACTIVE_TRANSACTION)
SQL ServerBackup & LogCommand
USE [Customer];
DBCC OPENTRAN;
-- Detailed: show long-running open transactions and their owners:
SELECT s.session_id, s.login_name, s.host_name, s.program_name,
t.transaction_id,
DATEDIFF(SECOND, t.transaction_begin_time, GETDATE()) AS duration_sec,
t.transaction_begin_time
FROM sys.dm_tran_active_transactions t
JOIN sys.dm_tran_session_transactions st ON st.transaction_id = t.transaction_id
JOIN sys.dm_exec_sessions s ON s.session_id = st.session_id
ORDER BY t.transaction_begin_time;What it does
Shows the oldest open (not committed/rolled back) transaction and the session holding it. An open transaction prevents log truncation (LOG_REUSE_WAIT = ACTIVE_TRANSACTION).
When to use it
To find the root cause when the log does not shrink despite log backups and log_reuse_wait_desc = ACTIVE_TRANSACTION.
Caution
Confirm with the business owner before KILLing the session holding a long open transaction; the rollback may take a long time. Query only; no risk.