xact-abort

set xact_abort on and try catch together

一世执手 提交于 2020-06-11 02:08:31
问题 i have a try catch block in my sp with just a insert statement in the try. the catch check error code if it is pk violation, if it is then do update. but some times i get "The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction. Uncommittable transaction is detected at the end of the batch. The transaction is rolled back." so i added xact_abort on, but then i keep getting "Transaction count after EXECUTE indicates a

How to make SET XACT_ABORT ON rollback the transaction?

北城余情 提交于 2020-01-14 08:05:16
问题 Based on the Books Online documentation of SET XACT_ABORT ON, i get the impression that if a T-SQL statement raises a run-time error, the entire transaction is terminated and rolled back: Remarks When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back. Testing this in SQL Server 2008 R2: SET XACT_ABORT ON; BEGIN TRANSACTION; PRINT 'TranCount befor an error = '+CAST(@@Trancount AS varchar(50)) DROP TABLE QuertyAsdf

How to make SET XACT_ABORT ON rollback the transaction?

烈酒焚心 提交于 2020-01-14 08:05:08
问题 Based on the Books Online documentation of SET XACT_ABORT ON, i get the impression that if a T-SQL statement raises a run-time error, the entire transaction is terminated and rolled back: Remarks When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back. Testing this in SQL Server 2008 R2: SET XACT_ABORT ON; BEGIN TRANSACTION; PRINT 'TranCount befor an error = '+CAST(@@Trancount AS varchar(50)) DROP TABLE QuertyAsdf

How to make SET XACT_ABORT ON rollback the transaction?

跟風遠走 提交于 2020-01-14 08:04:13
问题 Based on the Books Online documentation of SET XACT_ABORT ON, i get the impression that if a T-SQL statement raises a run-time error, the entire transaction is terminated and rolled back: Remarks When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back. Testing this in SQL Server 2008 R2: SET XACT_ABORT ON; BEGIN TRANSACTION; PRINT 'TranCount befor an error = '+CAST(@@Trancount AS varchar(50)) DROP TABLE QuertyAsdf

What is the effect of having XACT_ABORT on/off in parent/child stored procedures respectively?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 06:44:18
问题 I'm trying to improve the error handling of a current system to produce more meaningful error messages. I have a "root" stored procedure that makes several calls to other nested stored procedures. In the root sp, XACT_ABORT is set to ON but in the nested procedures, XACT_ABORT is set to OFF . I want to capture the specific errors from the lower level procedures rather than getting the root procedure's error. I often see the error, uncommittable transaction is detected at the end of the batch,

SET XACT_ABORT ON not Worked in Create Procedure

混江龙づ霸主 提交于 2019-12-13 06:41:58
问题 I use SQL Server 2008 SP3 (10.0.5500) And I have some Problems with Rollback Transactions, at first I need to know something. This is My create Procedure script: USE [MYDB] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET XACT_ABORT ON GO If Exists(Select * From Sys.Objects Where [object_id]=Object_Id(N'[Members].[MyProc]') And ObjectProperty([object_id], N'IsProcedure') = 1) Begin Drop Procedure [Members].[MyProc] Print 'Procedure [Members].[MyProc] Dropped!' End GO CREATE PROCEDURE

What is the effect of having XACT_ABORT on/off in parent/child stored procedures respectively?

一曲冷凌霜 提交于 2019-12-05 08:40:20
I'm trying to improve the error handling of a current system to produce more meaningful error messages. I have a "root" stored procedure that makes several calls to other nested stored procedures. In the root sp, XACT_ABORT is set to ON but in the nested procedures, XACT_ABORT is set to OFF . I want to capture the specific errors from the lower level procedures rather than getting the root procedure's error. I often see the error, uncommittable transaction is detected at the end of the batch, the transaction is being rolled back. Is there any effect to having these "mixed" environments with

SQL Server XACT_ABORT with exclusion

倖福魔咒の 提交于 2019-12-04 04:55:16
问题 I have a larger stored procedure which utilizes several TRY/CATCH blocks in order to catch and log individual errors. I have also wrapped a transaction around the entire contents of the procedure, so as to be able to roll back the entire thing in the event of an error raised somewhere along the way (in order to prevent a lot of messy cleanup); XACT_ABORT has been enabled since it would otherwise not roll back the entire transaction. Key component: There is a table in my database which gets a

SQL Server XACT_ABORT with exclusion

喜欢而已 提交于 2019-12-01 23:46:17
I have a larger stored procedure which utilizes several TRY/CATCH blocks in order to catch and log individual errors. I have also wrapped a transaction around the entire contents of the procedure, so as to be able to roll back the entire thing in the event of an error raised somewhere along the way (in order to prevent a lot of messy cleanup); XACT_ABORT has been enabled since it would otherwise not roll back the entire transaction. Key component: There is a table in my database which gets a record inserted each time this procedure is run with the results of operations and details on what went