22 September 2008

SQL Transaction

bit like in cfmx here's a useful bit of t-sql / sql for rolling back on error.

BEGIN TRAN
insert into ()--....sql goes here

IF @@ERROR <> 0
BEGIN
ROLLBACK TRAN
END
COMMIT TRAN

It's not perfect but it seems to work...sometimes....if the wind is blowing north, and it's a wednesday.

No comments: