Monday, December 27, 2010

All about roolback in SQL

If accidentally you did some CRUD operation in the table then, here I am telling how to get back to the previous stage.

BEGIN TRANSACTION;
update tblName set FirstName='test' where id=1;
rollback ;


this will get you back to your previous stage(UNDO).
And if you want to get-back any particular column data then go for it.

BEGIN TRANSACTION transiction_name;
update tbl_name set FirstName='test' where id=1;
rollback transaction transiction_name;

But don't do commit; unless rollback will not work any more.

0 comments:

Post a Comment