@@Error in SQL
What do you think the output of the following SQL program would be? Create table Test(testID tinyint) Begin Tran Insert into Test(testID ) values (1) PRINT @@ERROR Insert into Test(testID ) values (300) // This statement will generate an error as 300 is not a tinyint PRINT @@ERROR IF @@ERROR = 0 BEGIN COMMIT TRAN END ELSE BEGIN ROLLBACK TRAN END The transaction will be Committed :) Surprised?. Since, we have a PRINT @@ERROR statement before the IF statement, this condition will be executed as true and the output of @@ERROR will be 0.