Posts

Showing posts with the label XACT_ABORT

The XACT_ABORT option: What it is and what it is used for, all explained in a simple way!

Image
Hi Guys, Welcome back! After a dip in the maze of the logic of the SQL Server optimizer , today we talk about the command XACT_ABORT . We will see how important this command is when we deal with transactions. Do not worry, I will try to explain in the simplest way possible! XACT_ABORT The XACT_ABORT is an option which can have only two possible values: ON and OFF.   You can simply set it's value with the T-SQL command: SET XACT_ABORT ON OR SET XACT_ABORT OFF If XACT_ABORT is set to ON then if a T-SQL command throws an error then the transaction will be rollbacked . Suppose of having a trigger triggered by an update on the table A If an istruction inside the trigger fail then also the update on the table will be rollbacked . Yes, this is the concept. Let's have this example with XACT_ABORT set to ON Suppose we have a TABLE_A table with the field CAMPO1 non nullable with a 0 value . SET XACT_ABORT...