SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Undo the last run query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

akki1563
Starting Member

10 Posts

Posted - 04/02/2012 :  07:38:22  Show Profile  Reply with Quote

Hi,
I ran one update query without specifying where clause..The update query is not inside Transaction. Is there any way to roll back this update statement ?

Please let me know.

Regards,
Akki

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 04/02/2012 :  08:52:18  Show Profile  Reply with Quote
Ouch! None that I know of, Akki.

The only option that I know of is to restore your latest backup (to another location), get the data as it existed before the update, and then carefully recover the data you need.

Often times, when I have to make critical changes on a production server, I do the following:


-- 1
BEGIN TRAN
UPDATE SEcurities SET MarketPrice = 598.55 WHERE TICKER = 'AAPL';

-- 2
ROLLBACK

-- 3
COMMIT
I would run step 1, take a quick look to make sure it updated only one row, and then run step 3 if all seems well. Even this is dangerous on a production server, because you may be locking up a page, or more or locking up some hot rows etc.

Edited by - sunitabeck on 04/02/2012 08:53:20
Go to Top of Page

akki1563
Starting Member

10 Posts

Posted - 04/02/2012 :  09:59:40  Show Profile  Reply with Quote
Thanks sunitha.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 04/02/2012 :  10:17:43  Show Profile  Reply with Quote
Do you have a backup before the UPDATE?

If yes, you can restore the backup to a different database name, the copy the data over

Or

Maybe you can use lumigent log explorer


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30277 Posts

Posted - 04/02/2012 :  12:35:21  Show Profile  Visit SwePeso's Homepage  Reply with Quote
There are some log reader tools available, with which you may be able to "undo" the update.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000