Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recover Table data after updation

Status
Not open for further replies.

ISChana

Programmer
Dec 18, 2002
32
0
0
IN
I had accidently updated table as

update table
set name='somevalue', phone='somevalue'

So all the 700 records updated with this..

Can Anybody suggest how to get the previous data.(I have not taken backup for a long time)


thanks

Inder
 
Assuming your database isn't in Simple Recovery Mode, you might have a very big Transaction Log with all the data changes in it from the time of the last back up.

If this case you can restore from your full backup and then do a transaction log resotre with the "stop at" attribute (do a search on line)

If you don't, you are up the creek.. and the next part is a very good piece of advice for future habits (other than simply doing backups-and even then it will save you from this sort of problem)

If you are playing with statements that can change data and want to be able to recover (and you probably are tooooo farrr gone at this point) it is a good idea to start every update with a "Begin Tran" and no matching "commit"...

That way if you don't like what you did (and you don't have backups) you can always issue a "rollback".

The idea..
Code:
Begin Tran
Update tableX set col1 = 'go'
at the end of that
Code:
select * from tableX
If you don't like what you have
Code:
Rollback
If you do
Code:
Commit


HTH

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top