December 14, 2006 at 10:18 am
In one of my stored procedure I am Inserting the data into 3 tables.
BEGIN TRANSACTION trans1
Insert into tbla(column1)
VALUES(@variable1)
Insert into tblb(columna)
VALUES(@variable2)
Insert into tbla(columnx)
VALUES(@variable3)
IF @@ERROR<>0
BEGIN
ROLLBACK TRANSACTION tran1
December 14, 2006 at 10:23 am
sorry guys this is an incomplete post.
December 14, 2006 at 11:34 am
this is how i typically do a big group of transactions;
note that i use SET XACT_ABORT ON, which means if any error gets raised, it rollsback the transaction automatically, so i need never check for @@error:
SET NOCOUNT ON
SET XACT_ABORT ON
BEGIN TRAN
INSERT INTO TABLE1....
UPDATE TABLE1...
INSERT INTO TABLE2.....
COMMIT TRAN
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply