Correctly.
SET XACT_ABORT jumps out of the game. Your IF is part of the same batch.
If you want to handle the error, use BEGIN TRY, etc.
SET XACT_ABORT ON
BEGIN TRY
BEGIN TRANSACTION
COMMIT TRANSACTION
END TRY
BEGIN CATCH
raiserror('SP failed. Step 7.', 20, -1) with log
END CATCH
GO
I am also intrigued by the seriousness of 20 because it breaks the connection. Usually you should use 16, which is a user-defined error.
source
share