April 16, 2009 at 11:53 am
Hello,
This is my first time trying to use XACT_STATE. I found this below example on BOL. My question, do we need this check - IF XACT_STATE() =1? If we are inside a catch block, it means something went wrong, and we would just do a rollback, right? Why are we checking for this above condition and doing a commit?
Thanks.
BEGIN TRY
BEGIN TRANSACTION;
DELETE FROM Production.Product WHERE ProductID = 980;
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
IF (XACT_STATE()) = -1
ROLLBACK TRANSACTION;
IF (XACT_STATE()) = 1
COMMIT TRANSACTION;
END CATCH;
GO
April 16, 2009 at 3:04 pm
I just want to confirm your consideration. I also don't know a reason to commit a transaction if there was an error.
Greets
Flo
April 17, 2009 at 10:35 am
Bump. Anyone?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy