I'm new here so please be gentle! :) Ok, so I've got into the SQL Server community/world for about 2 years now (SQL Server Dev and DBA - 2005+ versions) and recently I have also discovered the ACID theory and I was just wondering how the hell is SQL Server ACID compatible? As a default it always comes with the XACT_ABORT OFF option, right? And here's an example from MSDN :
IF OBJECT_ID(N't2', N'U') IS NOT NULL
DROP TABLE t2;
GO
IF OBJECT_ID(N't1', N'U') IS 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 INTO t1 VALUES (1);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (6);
GO
SET XACT_ABORT OFF;
GO
BEGIN TRANSACTION;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (2); -- Foreign key error.
INSERT INTO t2 VALUES (3);
COMMIT TRANSACTION;
GO
select * from t2;
And the result set:
a
1
3
Where is the atomicity in this case? Did I got the whole ACID theory wrong perhaps?
P.S.:The reason I ask this is not just because of the ACID property but also because I have struggled many times in the past with this XACT_ABORT option and especially when it gets combined with CLR code from an app via ODBCs connections- but off topic :)