Reading things like this post on Dan Guzman's blog, I wonder: why isn't SET XACT_ABORT ON
the default behavior? Is there a case where it's harmful, or much less desirable/efficient than SET XACT_ABORT OFF
?
在Dan Guzman的博客上阅读这篇文章,我想知道:为什么SET XACT_ABORT没有默认行为?是否存在比SET XACT_ABORT OFF有害,或者更不可取/效率高的情况?
1 个解决方案
#1
10
It's an automatic response to an error, it's more desirable if you can handle the error and recover from it. If the transaction automatically rolls back then you don't get this opportunity.
它是对错误的自动响应,如果您可以处理错误并从中恢复,则更为可取。如果交易自动回滚,那么您就没有机会。
The problem Dan mentions in his blog arises because of the abort from the client, within SQL this abort doesn't exist. Hence within SQL the default is not to automatically abort transactions.
Dan在他的博客中提到的问题是由于客户端的中止,在SQL中这种中止不存在。因此,在SQL中,默认情况下不会自动中止事务。
#1
10
It's an automatic response to an error, it's more desirable if you can handle the error and recover from it. If the transaction automatically rolls back then you don't get this opportunity.
它是对错误的自动响应,如果您可以处理错误并从中恢复,则更为可取。如果交易自动回滚,那么您就没有机会。
The problem Dan mentions in his blog arises because of the abort from the client, within SQL this abort doesn't exist. Hence within SQL the default is not to automatically abort transactions.
Dan在他的博客中提到的问题是由于客户端的中止,在SQL中这种中止不存在。因此,在SQL中,默认情况下不会自动中止事务。