Do I really need to use quot;SET XACT_ABORT ONquot;?(我真的需要使用“SET XACT_ABORT ON吗?)
问题描述
如果你很小心并且在所有事情上都使用 TRY-CATCH 并且回滚错误,你真的需要使用:
if you are careful and use TRY-CATCH around everything, and rollback on errors do you really need to use:
SET XACT_ABORT ON
换句话说,是否有任何 TRY-CATCH 会错过 SET XACT_ABORT ON 将处理的错误?
In other words, is there any error that TRY-CATCH will miss that SET XACT_ABORT ON will handle?
推荐答案
请记住,无论是否使用 XACT_ABORT
,TRY-CATCH 都不会捕获某些错误.
Remember that there are errors that TRY-CATCH will not capture with or without XACT_ABORT
.
但是,SET XACT_ABORT ON
不影响捕获错误.它确实保证任何事务都会回滚/注定失败.当OFF"时,您仍然可以选择提交或回滚(取决于 xact_state).这是 SQL 2005 XACT_ABORT
如果客户端命令超时并且客户端发送中止"指令,它还会移除锁等.如果没有 SET XACT_ABORT
,如果连接保持打开状态,锁可以保留.我的同事(MVP)和我在年初彻底测试了这个.
What it also does is remove locks etc if the client command timeout kicks in and the client sends the "abort" directive. Without SET XACT_ABORT
, locks can remain if the connection remains open. My colleague (an MVP) and I tested this thoroughly at the start of the year.
这篇关于我真的需要使用“SET XACT_ABORT ON"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我真的需要使用“SET XACT_ABORT ON"吗?


- 在SQL中,如何为每个组选择前2行 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01