Categories
MSSQL Server

MSSQL Query Session Information

Get info on non-sleeping sessions or open open transactions.

SELECT DB_NAME(database_id) AS dbname, *
FROM sys.dm_exec_sessions WHERE 1=1
AND is_user_process > 0
AND ( open_transaction_count > 0 OR status <> 'sleeping' )
ORDER BY database_id