Here is a simple test I coded.
SET XACT_ABORT ON
BEGIN TRANSACTION
GO
CREATE PROCEDURE [usp_MyTest1]
AS
GO
CREATE PROCEDURE [usp_MyTest1]
AS
GO
CREATE PROCEDURE [usp_MyTest2]
AS
GO
COMMIT TRANSACTION
It was my understanding that since I have SET XACT_ABORT ON
, when the second create procedure fails, the entire transaction will roll back. Instead, only things proceeding the error (the first create procedure) are rolled back and the last create procedure executes just fine. I then get a message saying The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
I've seen people have an issue with RAISEERROR, but the documentation for XACT_ABORT says that RAISEERROR does not honnor XACT_ABORT. But this doesn't mention anything about an error such as creating a duplicate procedure not honoring XACT_ABORT.
https://learn.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact-sql
The THROW statement honors SET XACT_ABORT RAISERROR does not. New Applications should use THROW instead of RAISERROR.
This is with SQL Server 2012, if that is relevant.