Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ROLLBACK Transaction Expand / Collapse
Author
Message
Posted Thursday, February 5, 2009 4:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 11, 2009 3:11 AM
Points: 12, Visits: 27
Gurus,

In a session i have run the UPDATE statement..but accidentely i pressed EXECUTE..

Steps:

1. update statement without WHERE clause.
2. Click on 'EXECUTE'.

So is there any way that i retrieve the old data for the table...

Please help,

NOTE: I have not done any DECLARE for transaction.



Regards,
~Sri
Post #650692
Posted Thursday, February 5, 2009 4:07 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,065, Visits: 4,639
It looks to me your transaction got commited.

How about point-in-time recovery?


_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #650697
Posted Thursday, February 5, 2009 4:44 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097, Visits: 2,157
Do you have any backups taken? If so, you can restore it to a different database and copy the table to the database which lost the data.
Post #650710
Posted Thursday, February 5, 2009 4:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 11, 2009 3:11 AM
Points: 12, Visits: 27
yes,my transaction got committed...i guess i need to perform recovery.
Post #650715
Posted Thursday, February 5, 2009 4:54 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097, Visits: 2,157
sridhar.tondapi (2/5/2009)
yes,my transaction got committed...i guess i need to perform recovery.


Then, Restore it to a different database name and copy the table to the target database.
Post #650717
Posted Thursday, February 5, 2009 7:31 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 6:43 PM
Points: 2,838, Visits: 8,570
And next time use a BEGIN TRAN so you can roll back if needed.

FYI, when making changes to data like this, I usually take a few precautions.

1. Back up the table first by creating a copy with a different name, such as:
select * into Table_20090205
from Table

2. Run a select to see how many records will get updated and Review the data to make sure it looks like the right records:
select * FROM Table_20090205
WHERE ColumnA Is Null


3. I would run the update in a transaction so you can undo it right then if you make a mistake:
begin tran

UPDATE T SET ColumnA = 'NewValue'
FROM Table T
WHERE ColumnA Is Null

rollback
commit

If you get the correct count, then: COMMIT
If you think it's wrong and need to undo, then : ROLLBACK

If you accidentally run the script all at once, having the rollback in there will undo it

4. When you're all finished, save the whole script somewhere in case you need to look back sometime.
Record the number of rcds changed in the script



Post #650852
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse