有没有办法在 SQL Server 2000 数据库上列出打开的事务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4449719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to list open transactions on SQL Server 2000 database?
提问by James Wiseman
Does anyone know of any way to list open transactions on SQL Server 2000 database?
有谁知道在 SQL Server 2000 数据库上列出打开的事务的任何方法?
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.
我知道我可以sys.dm_tran_session_transactions
在 SQL 2005(及更高版本)数据库版本上查询视图,但是这在 SQL 2000 上不可用。
回答by gbn
For all databases query sys.sysprocesses
对于所有数据库查询 sys.sysprocesses
SELECT * FROM sys.sysprocesses WHERE open_tran = 1
For the current database use:
对于当前数据库使用:
DBCC OPENTRAN
回答by Rinoy Ashokan
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
and you close that transaction by the help below KILLquery by refering session id
并且您通过引用会话 id 通过下面的帮助关闭该事务KILL查询
KILL 77
回答by codingbadger
DBCC OPENTRANhelps 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.
DBCC OPENTRAN有助于识别可能阻止日志截断的活动事务。DBCC OPENTRAN 显示有关指定数据库的事务日志中最早的活动事务以及最早的分布式和非分布式复制事务(如果有)的信息。仅当日志中存在活动事务或数据库包含复制信息时才会显示结果。
An informational message is displayed if there are no active transactions in the log.
如果日志中没有活动事务,则会显示一条信息性消息。
回答by kanti
Use this because whenever transaction open more than one transaction then below will work SELECT * FROM sys.sysprocesses WHERE open_tran <> 0
使用这个是因为每当事务打开一个以上的事务时,下面将起作用 SELECT * FROM sys.sysprocesses WHERE open_tran <> 0