4

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?

  • 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

5 Answers5

5

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

If you were not, than restore from backup

4

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.

Davide Piras
  • 163
  • 8
2

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

Martin
  • 121
  • 2
0

Not if you don't have a backup.

0

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.

Bohemian
  • 201
  • 1
  • 6