是否会自动回滚死锁事务? [英] Will a deadlocked transaction be rolled back automatically?

查看:470
本文介绍了是否会自动回滚死锁事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我正在使用事务在后端使用Sqlserver 2005执行操作。

如果发生死锁错误(即)返回错误号,因为1205将回滚死锁事务或特定事务将失败。



Hi,
I am using transactions to perform operations at the back end using Sqlserver 2005.
If deadlock error occurs(i.e) Error number is returned as 1205 will that deadlocked transaction be rolled back or that particular transaction will fail.

Begin Try
begin Transaction Save

Update Table1  -----Executed Process
Update Table2  -----Deadlocked Process

Commit Transaction Save
End Try

Begin Catch	

if(ERROR_NUMBER() <> 1205)
    RollBack Transaction

End Catch	





这里有如果Table1成功更新并且Table2死锁,那么更新DML语句将失败或第二个DML语句失败。



我需要一个解决方案。

很高兴得到帮助......



Here in the above transaction if Table1 gets updated successfully and Table2 is deadlocked then will both the update DML statements fails or the Second DML Statement fails.

I need a solution for this.
Helpers are appreciated...

推荐答案

这可能有助于解决您的问题。 SQL SERVER - 如何处理死锁



希望它有所帮助。
This will probably help to resolve your issue. SQL SERVER - How To Handle Deadlock

hope its helps.


这篇关于是否会自动回滚死锁事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆