Possible Duplicate:
How to rollback a deleted table data?

I accidentally ran an update statement against my database. Is there a way to roll back this single update without disrupting the rest of the database?

marked as duplicate by Mark Henderson Aug 29 '11 at 1:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Aug 28 '11 at 13:48

This question came from our site for professional and enthusiast programmers.

  • 5
    What RDBMS? If SQL Server what is your recovery model and have you ever taken a full database backup? – Martin Smith Aug 28 '11 at 13:37
  • 6
    And that kids is why we always back up our database and test our update queries to see if they do what we want them to do! – cularis Aug 28 '11 at 13:39

Were you in a transaction? If yes, try entering ROLLBACK WORK;

If you were not, than restore from backup


no, if the update has been completed successfully, I assume you used SQL Server Management Studio, the changes have been applied.

if it's really important that you revert those updates, you should restore the last backup if you have one and don't bother to loose changes done between backup time and now.


Get a backup restored, and rollforward to the point just before your accidental update. See http://msdn.microsoft.com/en-us/library/ms191455.aspx


Not if you don't have a backup.


Yes. You must shutdown your database and, using db admin tools, restore the database from the latest backup and roll forward through the log to a point in time just before your update. You will lose all updates made after that point of course, not just your accident.

I can't be more specific than that because you haven't shown which database you are using, but all databases have a log that can be used in this way.