• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

How to get the changed values in a table

I changes some table value in some table using update command...

How can we change to the previous value?
0
jaisonshereen
Asked:
jaisonshereen
  • 3
  • 2
  • 2
2 Solutions
 
Patrick MatthewsCommented:
jaisonshereen said:
>>How can we change to the previous value?

Unless you started a transaction and have not yet committed the tran, or unless you backed up the old data
somewhere (new table; backup of whole db), you can't.
0
 
Patrick MatthewsCommented:
matthewspatrick said:
>>Unless you started a transaction and have not yet committed the tran, or unless you backed up the old data
>>somewhere (new table; backup of whole db), you can't.

Make that, you can't do it easily.  You may be able to use products that read the log, and reverse the update
that way...
0
 
jaisonshereenAuthor Commented:
actully i did a simple thing

suppose a table abc having column def and have a row for a value of ghj

i did this :

update abc set def=30 where ghj="hello"

how to get the previous value of def?

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
chapmandewCommented:
matthew is correct, you likely can't unless you're in full recovery mode and have a tool to read the logs.
0
 
Patrick MatthewsCommented:
jaisonshereen said:
>>update abc set def=30 where ghj="hello"
>>
>>how to get the previous value of def?

If, and only if, all of the updated records had a single value before, and you know what that value was, you could
do this:

update abc set def=1 where ghj="hello"

Now, that assumes the following:
1) All the updated rows previously had def=1
2) All the updated rows *still have* ghj='hello', *and* no non-updated rows now have ghj='hello'

If either of those assumptions are not ture, you are hosed, unless you have some sort of backup.
0
 
jaisonshereenAuthor Commented:
so if go for a backup..everything what i did after that will also loose right?
0
 
chapmandewCommented:
don't restore the backup over your current db...restore it w/ a new db name, and use the values in that db to replace what you did in your update statement.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now