I was just surprised at something in TSQL. I thought that if xact_abort is enabled, something like
raiserror('Something bad happened', 16, 1);
terminates the execution of the stored procedure (or any batch).
But my ADO.NET error message just proved the opposite. I received a raiserror error message in the exception message, as well as the following, which then broke.
This is my workaround (this is my habit anyway), but it doesn't seem like it's necessary:
if @somethingBadHappened begin; raiserror('Something bad happened', 16, 1); return; end;
The docs say the following:
When SET XACT_ABORT is turned on, if the Transact-SQL statement raises a run-time error, the whole transaction is completed and rolled back.
Does this mean that I should use an explicit transaction?
sql sql-server tsql
Eric Z Beard Sep 16 '08 at 20:04 2008-09-16 20:04
source share