SQL 如何杀死或回滚活动事务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3978227/
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
How to kill or rollback active transaction?
提问by ogun
How can I kill or rollback, uncommitted transaction?
如何终止或回滚未提交的事务?
I am listing my active transactions with the following sql:
我正在使用以下 sql 列出我的活动事务:
SELECT * FROM sys.dm_tran_session_transactions
My result is:
我的结果是:
session_id transaction_id transaction_descriptor enlist_count is_user_transaction is_local is_enlisted is_bound
----------------------------------------------------------------------------------------------------------------------
54 117260 0x0100000036000000 0 1 1 0 0
I dont want to kill the session (54)...
我不想杀死会话(54)...
Thanks all
谢谢大家
采纳答案by orka
You can't kill/rollback a transaction from another session without killing the owner session.
您不能在不终止所有者会话的情况下终止/回滚另一个会话的事务。
I think, allowing to kill/rollback a transaction from another user's session means many design and security rule violations because it requires entering another user session (in the context of the current sql server engine design). That's probably why it is not implemented.
我认为,允许从另一个用户的会话中终止/回滚事务意味着许多设计和安全规则违反,因为它需要进入另一个用户会话(在当前 sql server 引擎设计的上下文中)。这可能就是它没有实施的原因。
回答by Arun Prasad E S
To clear all transaction, Use this only as a temp solution
要清除所有交易,仅将此用作临时解决方案
ALTER DATABASE DatabaseName
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
ALTER DATABASE DatabaseName
SET MULTI_USER;
refer this sitefor more info
参考这个网站了解更多信息
Points to check - it also rollbacks committed transactions
检查要点 - 它还回滚已提交的事务