How to rollback accidentally updated statement in sql server.

Posted by Vishalneeraj-24503 under Sql Server on 6/11/2015 | Points: 10 | Views : 1954 | Status : [Member] [MVP] | Replies : 2
Can anyone please tell me how to rollback update statement that is by-mistakenly fired on table?
I want to rollback the entire data on one table.




Responses

Posted by: Bandi on: 6/12/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
If you still have transaction in open state, you can rollback the Updated data.
i.e.

BEGIN TRANSACTION
--Update statement


Now the transaction is in open state. You can undo the transaction by using rollback statement....

BEGIN TRANSACTION 
--Update statement
Rollback Transaction


If you want to close the transaction by saving updated data to database, you can do as follows:
BEGIN TRANSACTION 
--Update statement
commit Transaction


NOTE: If you doesn't have transaction open and the data updated to database accidentally, then you must restore a database backup. If you're using Full backups, then you should be able to restore the database to a specific point in time.


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Vishalneeraj-24503, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 6/12/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi Vishal,

If you have time and wanted to work on it more, i found one blog post to recover modified/updated data from DB without using any restore process..

Do the research and let us know if it works out for you...
http://raresql.com/2012/02/01/how-to-recover-modified-records-from-sql-server-part-1/


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Vishalneeraj-24503, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response