sql - XACT_ABORT OFF ACID incompatible? -
i'm new here please gentle! :) ok, i've got sql server community/world 2 years (sql server dev , dba - 2005+ versions) , have discovered acid theory , wondering how hell sql server acid compatible? default comes xact_abort off option, right? , here's example msdn :
if object_id(n't2', n'u') not null drop table t2; go if object_id(n't1', n'u') not null drop table t1; go create table t1 (a int not null primary key); create table t2 (a int not null references t1(a)); go insert t1 values (1); insert t1 values (3); insert t1 values (4); insert t1 values (6); go set xact_abort off; go begin transaction; insert t2 values (1); insert t2 values (2); -- foreign key error. insert t2 values (3); commit transaction; go select * t2;
and result set:
a 1 3
where atomicity in case? did got whole acid theory wrong perhaps?
p.s.:the reason ask not because of acid property because have struggled many times in past xact_abort option , when gets combined clr code app via odbcs connections- off topic :)
yep, right. when used that, xact_abort off , without try/catch blocks, transactions in sql server pretty useless.
you should use xact_abort_on , try/catch blocks make transactions safe.
in case try/catch work xact_abort off:
set xact_abort off; go begin try begin transaction; insert t2 values (1); insert t2 values (2); -- foreign key error. insert t2 values (3); commit transaction; end try begin catch rollback; end catch go