Answers:
您可以通过以下查询获取活动交易的所有信息
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
然后通过引用会话ID通过KILL查询下面的帮助关闭该事务
KILL 77
DBCC OPENTRAN帮助确定可能阻止日志截断的活动事务。DBCC OPENTRAN在指定数据库的事务日志中显示有关最旧的活动事务以及最旧的分布式和非分布式复制事务的信息。仅当日志中存在活动事务或数据库包含复制信息时,才会显示结果。
如果日志中没有活动的事务,则会显示参考消息。