Is there a way to list open transactions on SQL Server 2000 database?
Asked Answered
C

4

133

Does anyone know of any way to list open transactions on SQL Server 2000 database?

I am aware that I can query the view sys.dm_tran_session_transactions on SQL 2005 (and later) database versions, however this is not available on SQL 2000.

Clothing answered 15/12, 2010 at 12:10 Comment(0)
S
220

For all databases query sys.sysprocesses

SELECT * FROM sys.sysprocesses WHERE open_tran = 1

For the current database use:

DBCC OPENTRAN
Serenata answered 15/12, 2010 at 12:45 Comment(0)
C
59

You can get all the information of active transaction by the help of below query

SELECT
trans.session_id AS [SESSION ID],
ESes.host_name AS [HOST NAME],login_name AS [Login NAME],
trans.transaction_id AS [TRANSACTION ID],
tas.name AS [TRANSACTION NAME],tas.transaction_begin_time AS [TRANSACTION 
BEGIN TIME],
tds.database_id AS [DATABASE ID],DBs.name AS [DATABASE NAME]
FROM sys.dm_tran_active_transactions tas
JOIN sys.dm_tran_session_transactions trans
ON (trans.transaction_id=tas.transaction_id)
LEFT OUTER JOIN sys.dm_tran_database_transactions tds
ON (tas.transaction_id = tds.transaction_id )
LEFT OUTER JOIN sys.databases AS DBs
ON tds.database_id = DBs.database_id
LEFT OUTER JOIN sys.dm_exec_sessions AS ESes
ON trans.session_id = ESes.session_id
WHERE ESes.session_id IS NOT NULL

and it will give below similar result enter image description here

and you close that transaction by the help below KILL query by refering session id

KILL 77
Cyton answered 8/8, 2017 at 12:20 Comment(1)
Wow, this one is very nice, i like the amount of data provided, the only con is that you need to be administrator in order to run it, DBCC OPENTRAN needs fewer permissions. But still... very goodDannie
N
31

DBCC OPENTRAN helps to identify active transactions that may be preventing log truncation. DBCC OPENTRAN displays information about the oldest active transaction and the oldest distributed and nondistributed replicated transactions, if any, within the transaction log of the specified database. Results are displayed only if there is an active transaction that exists in the log or if the database contains replication information.

An informational message is displayed if there are no active transactions in the log.

DBCC OPENTRAN

Nebulize answered 15/12, 2010 at 12:15 Comment(0)
D
4

Use this because whenever transaction open more than one transaction then below will work

SELECT * FROM sys.sysprocesses WHERE open_tran <> 0
Dorsman answered 27/1, 2020 at 7:35 Comment(1)
What is the context on "open more than one transaction"? Can you elaborate on that, for it is unclear what is being presented and the why it is needed.Adlai

© 2022 - 2024 — McMap. All rights reserved.