November 26, 2008 at 11:20 am
I ran a query which I want to roll back the actions of it. I did an update statement and failed to put in my where clause and updated about 300 records incorrectly. Is it possible to do this?
This is the statement I ran: update iworker_mstr set iworker_site_id = 2486195.
November 26, 2008 at 11:54 am
If you didn't nest your update in a transaction, and you don't have implicit transactions turned on for your connection... then no.
Restore your database with a different name, and update your values to what they were from the backup.
This is why, whenever you're updating a production database, use transactions, and type everything out to do the update and verify the update ahead of time, that way you can very quickly make the change, check it, and commit it or roll it back with the least amount of effect on everyone.
November 26, 2008 at 12:04 pm
Actually, my first post isn't necessarily true. You may be able to restore the db and the transaction logs up to the point of your bad update query if you have the right logging method set on your db, but I don't know enough about that to explain it.
November 26, 2008 at 12:15 pm
Yeah, point in time recovery depends on the database using full or bulk-logged recovery model. So more information is needed from the OP.
Greg
November 26, 2008 at 12:27 pm
Garadin (11/26/2008)
You may be able to restore the db and the transaction logs up to the point of your bad update query if you have the right logging method set on your db, but I don't know enough about that to explain it.
DB must be in full or bulk-logged recovery.
There must be a full backup.
There must be a complete, unbroken chain of transaction log backups from the full backup to after the bad update.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 26, 2008 at 12:29 pm
Thanks guys for your quick responses! This has helped out alot
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply