Question:
So i want to check if can update the table RegEnfermeiro (if not then rollback), if it can update then checks if can update the table RegEnfAtiv, if it fails rollback this one and the RegEnfemeiro, and the process continous to the next one. I thought this would works but it doesnt. Can someone explain how can i make this works?”’
Answer:
You would be better off usingXACT_ABORT
here. From the documentation:When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back.
This’ll mean that if one statement in the procedure fails, all the statements will be rolled back:
If you have better answer, please add a comment about this, thank you!