MagicMike is right, but I implemented another solution that I know to be effective (even if its solution seems more elegant). FYI, my solution with two transactions and pure error management (the error function @@ exists on SQL Server, check the equivalent on your SQL, in Oracle it should be something like "exceptions when others" instead of "If (error @@) = 0) "):
begin tran ALTER TABLE [dbo].[Table1] CHECK CONSTRAINT [FK_1] IF (@@Error=0) begin COMMIT TRAN end else begin rollback tran END begin tran ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_2] IF (@@Error=0) begin COMMIT TRAN end else begin rollback tran END
source share