Tag Archives: display active transaction

DBCC OPENTRAN in Microsoft SQL Server

Check the transaction information for the database in SQL Server

Displays information about the oldest active transaction and the oldest distributed and non-distributed replicated transactions, if any, within the specified database. Results are displayed only if there is an active transaction or if the database contains replication information. An informational message is displayed if there are no active transactions.

Syntax

DBCC OPENTRAN
(    { 'database_name' | database_id} )
[ WITH TABLERESULTS
[ , NO_INFOMSGS ]
]


Remarks
If neither database_name nor database_id is specified, the default is the current database.

Use DBCC OPENTRAN to determine whether an open transaction exists within the log. When using the BACKUP LOG statement, only the inactive portion of the log can be truncated; an open transaction can cause the log to not truncate completely.

Examples
This example obtains transaction information for the current database and for the pubs database.

-- Display transaction information only for the current database.
DBCC OPENTRAN
GO

-- Display transaction information for the pubs database.
DBCC OPENTRAN('pubs')