Transaction

  • A Transaction is a logical unit of work in which, all the steps must be performed or none.
  • A transaction is enclosed in "BEGIN TRAN" and "COMMIT TRAN".
  • E.g.,:

BEGIN TRAN

UPDATE tableName1
SET fieldname = newValue
WHERE fieldname = condition
UPDATE tableName2
SET fieldName = newValue
WHERE fieldName = condition
IF @@error != 0
BEGIN
ROOLBACK TRAN
PRINT 'Error occured, no rows updated'
RETURN
END
COMMIT TRAN

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger