Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Rollback committed transaction

Author  Topic 

Mayank
Starting Member

2 Posts

Posted - 2007-06-27 : 02:52:51
Hi,
I m performing changes on database with button click. Now i want to give a functionality to revert back all last changes done on some event like button click at any time(may be after week).So what are possible ways to implement such functionality.

Thanks in advance,

Mayank

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-06-27 : 04:30:14
You will have to record whatever the reverse of a change would be into a log table so you can replay it later. You can do this at the business functionality level or at the DB level. You can maybe get away with code-generating triggers for each table. It could get hairy around referential integrity & cascade deletes depending on how you have that set up.
Approaching it from the business function side means essentially doing the same thing but looking carefully at the effect you are trying to achieve and writing specific code for each case. It can be better, can be more time consuming and error prone.

Or you can take a backup when you are in a state you might wish to revert to.
Go to Top of Page

Mayank
Starting Member

2 Posts

Posted - 2007-06-27 : 04:44:13
Thanks for reply,
Actually i was finding a functionality like rollback transaction.
In case of error sql allow us to rollback all changes made.So is there any way to rollback transaction made(also committed) in sql.Also there is no issues regarding data consistency.Because it is the last operation performed on data , so reverting back will not create ant inconsistency.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-06-27 : 04:50:54
no there is no such rollback.

you'll have to restore a backup

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-27 : 05:28:41
Dunno if this helps, but we have a Trigger on some of our tables that stores the "History" of changes.

On our Admin forms for those tables we have a "Changes history" which displays all the changes, and next to each row is a "Revert" button that allows the user to reset the record to that set of values. A sort of "Undo" but it also allows the operator to see what other changes have been made since (if any) so that they are making an informed choice about the Revert.

Sometimes they choose to cut&paste certain of the values, instead of Revert, so that they can influence which of the recent changes are kept / discarded

Kristen
Go to Top of Page
   

- Advertisement -