[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get the changed values in a table

Posted on 2008-11-07
7
Medium Priority
?
243 Views
Last Modified: 2012-05-05
I changes some table value in some table using update command...

How can we change to the previous value?
0
Comment
Question by:jaisonshereen
  • 3
  • 2
  • 2
7 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 22904299
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
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 22904312
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
 

Author Comment

by:jaisonshereen
ID: 22904356
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 60

Expert Comment

by:chapmandew
ID: 22904378
matthew is correct, you likely can't unless you're in full recovery mode and have a tool to read the logs.
0
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 22904424
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
 

Author Comment

by:jaisonshereen
ID: 22904515
so if go for a backup..everything what i did after that will also loose right?
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 1000 total points
ID: 22904543
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

Featured Post

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.

Question has a verified solution.

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

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

873 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