What happens here? SQL Server - XACT_ABORT ON + @@ERROR Checking . .
-
12-11-2019 - |
Question
What happens with this type of scenario?
SET XACT_ABORT ON
BEGIN TRANSACTION
---DO SOMETHING HERE THAT CAUSES AN ERROR
COMMIT TRANSACTION
if @@error != 0
raiserror('SP failed. Step 7.', 20, -1) with log GO
My guess is that because XACT_ABORT
is ON
the COMMIT TRANSACTION
never happens (because the whole thing is rolled back and terminated), and neither does the last statement (checking for @@error
and then calling raiseerror
).
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow