Solved

how to undo the last command in SQL Query analyzer?

Posted on 2004-10-03
6
6,261 Views
Last Modified: 2009-07-29
hello guys, I'm desperately need your help immediately.

i have issued a statement on my sql query analyzer that change all other record on a table. how do i undo this statement?

e.g.

instead of committing this statement

update table1 set column1 = 'a' where column2 = '1' and column3 = '2' and column1 <> 'z'

i typed the wrong statement

update table1 set column1 = 'a' where column1 <> 'z'

which changes all other record on table 1 rather than records with column1 = 'z'

here's the question. How do i undo the statement like we do to undo the last action in msword, msexcel and other app programs.

sorry about this question, all i got is 190 points. Please help me right now. I've been balancing this records to reconcile the subsidiary ledgers.


thanks.
0
Comment
Question by:elatagaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 64 total points
ID: 12214291
There is no Undo in SQL Server. You either have to restore from backup, or use a 3rd party tool that can undo from the Log files -- however, if your log files get reused or wiped, it will be impossible even for 3rd party tools. Unfortunately, it costs. The best tool is Log Explorer from Lumigent (www.lumigent.com). There's a trial version, but it only works with SQL Server sample databases pubs and Northwind.
0
 
LVL 1

Assisted Solution

by:AntonG
AntonG earned 63 total points
ID: 12214849
i must agree with jdlambert1.... what he says there is quite accurate.

In future, you should try to wrap Transactional statements around your queries.

That way, you could always ROLLBACK the transactions, but unfortunately, the situation you are currently in sort of renders you helpless.
0
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 63 total points
ID: 12218007
If you have a db backup and log backup, you could also forward recover the db to the point just before you issued the command.  For example, if the command was issused at 11:17a, roll forward to 11:16a (or 11:15a to be safe).

Btw, as you now know, it is safest to always first run UPDATE as SELECT and *make sure* it affects only the row(s) you expect it to effect.  So, instead of starting with:

update table1
set column1 = 'a'
where column1 <> 'z'

Start with:

SELECT *
FROM table1
WHERE column1 <> 'z'

Then, if the number of rows and values look OK, then you issue the UPDATE (or DELETE).
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Many to one in one row 2 40
SQL Server 2008 Std. License Key owner or vendor 4 56
T-SQL Query - Group By Year 3 31
Need multiple Group By's 8 27
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

733 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