[Last Call] Learn how to a build a cloud-first strategyRegister Now


Accidently update a table, How can I recover??

Posted on 2005-05-09
Medium Priority
Last Modified: 2012-05-05
Hi, Guru,

I accidently update the wrong rows of one table in the MS SQL server through Query Analyzer. How can I recover the old result? Somebody said the "ROLLBACK". But it gave me the error: "The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION."

I am new on the Database, how can I recover the old result? Thanks.

Question by:suwanee
LVL 66

Accepted Solution

Jim Horn earned 172 total points
ID: 13961038
You can't.  Do you have a backup, and can you modify the UPDATE query to effectively un-do the previous one?

The rollback you are referring to is when you use transactions in code, and surround your queries in them.  Using Access VBA it goes like this...
Dim cn as ADODB.Connection
Set cn = CurrentProject.Connection


cn.Execute "Query 1"
cn.Execute "Query 2"
cn.Execute "Query 3"

If Whatever then 'error trapping, records affected, whatever criteria you want...
End If

Hope this helps.

Author Comment

ID: 13961084
No, I don't have backup, and I don't know the old results. It got to be a problem.
LVL 66

Expert Comment

by:Jim Horn
ID: 13961117
You may be hosed here.  Can you re-import the table from whatever the source of its data was?

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

LVL 25

Assisted Solution

jrb1 earned 164 total points
ID: 13961588
There are a couple of products that might help you (free trials).  They both read the transaction logs and allow for changes to be undone.

Go here:


Look for ApexSQL Log.  It is supposed to generate Undo scripts for you.

Or try Lumigent's Log Explorer:


You should be able to "Undo a single operation or multiple transactions" with this product.

Expert Comment

ID: 13964862
On the bright side, you may have your first really good example of "Why we must do backups". If you cant recover the data you may want to keep a record of this incident to refer to whenever you are getting a bit lazy on the backup front, or when someone tells you that you dont really need backups.

LVL 60

Assisted Solution

by:Julian Hansen
Julian Hansen earned 164 total points
ID: 13966333
Here is a tip for the future.

I had a similar problem a while back and it cost me dearly. Since then I do the following when making any data changes to my database.

Assume QA

Before making changes to the database run the following command


Now do all the updates you want - make sure you don't close your session or you will kill the transaction frame

After updates check that all is well - if you are happy run the following


if you are not run


This is not a substitute for backups but is a useful technique to avoid having to use the backups.


Expert Comment

ID: 16170508
I think Jim and Jrb both supplied pertinent answers given the information they had at the time. I feel my advice is just as applicable as julians, given that by the time julian answered we knew that the transaction had not been declared. For future use, my advice on backups is just as if not more useful than transaction rollback syntax.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question