SQL TRANSACTION EXAMPLE

Category : ADO / SQL

BEGIN TRAN
–Delete from table.
DELETE FROM blah where blah

IF @@ERROR <> 0
BEGIN
ROLLBACK TRAN
return -1
END

–NOW delete from other table
DELETE FROM blah2 where blah2

IF @@ERROR <> 0
BEGIN
ROLLBACK TRAN
return -1
END

COMMIT TRAN

Post a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word