SET XACT_ABORT ON changes the behavior of errors that end with the application so that they instead become packet interrupt errors. The package in which your procedure runs is likely to stop completely when an error occurs, rather than continuing with the next T-SQL statement.
It matters for error handling. Errors with completion of the output, which usually allow you to continue and process the code using the IF @@ERROR <> 0 block inside your procedure, will not be executed. To make matters worse, you cannot intercept batch abortion in T-SQL code, so if you donβt check for @@ERROR immediately in the next batch in the same connection, you may not know that there was a problem.
Perhaps your INSERT is failing in some way, which allows you to increase the seed of IDENTITY . This is not uncommon ... identity values ββare in the memory cache of SQL Server, whose volatility does not guarantee that these values ββwill be continuous without spaces.
Alternatively, the context of the stored procedure call makes sense. If it is called from an external visibility transaction initiated by SQL Server or at the application level, then the rollback in this external area rolls back the internal work of the area, regardless of the explicit transaction processing code in the internal area. Again, the seed of IDENTITY will increase.
Blocks
TRY/CATCH (available with SQL Server 2005) eliminates the need for SET XACT_ABORT ON .
source share