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?

link|improve this question
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
feedback

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

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

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

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

5 Answers

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.

link|improve this answer
feedback

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

If you were not, than restore from backup

link|improve this answer
feedback

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

link|improve this answer
feedback

Not if you don't have a backup.

link|improve this answer
feedback

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.

link|improve this answer
1  
transaction log is to rollforward, not to rollback, unless the transaction had not done it's commit yet. – Martin Aug 28 '11 at 13:48
3  
You are right - answer modified. btw, "its" has no apostrophe when used in the possessive, ie it should be done its commit. – Bohemian Aug 28 '11 at 13:52
feedback