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?
jaisonshereenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.