Is there any way that we can revert/rollback after updating data ?

  • I am using SQL server 2000.

    By mistake I have updated few records without using begin statement.

    Right now I have to rollback this transaction. How could I do this.

    Is there any way. Plz reply...

  • Do you have a backup of your database? If so, start by backing up your transaction log now and then restore the database to a different location and apply the transaction log backup with a STOPAT just before you did the update. Then import the original data from there into your main database.

    If you don't have a backup, you're probably stuck. Please post your UPDATE statement so we can see whether there's anything at all that can be done.

    John

  • Yes we r taking backup .

    Right now I have full backup of last Sunday

    Differential backup of todays morning and current log backup.

    What is meaning of ''Then import the original data from there into your main database.'' which u have mentioned.

    Here I am using simple query

    update ed_mainorg set Orgname='A'+substring(orgname,1,6) where Orgname

    like 'Inc%'

    How could I go..

  • OK, I don't think you can just back that query out. So what you need to do is restore to a different database, then do something like this:

    UPDATE d

    SET d.Orgname = r.Orgname

    FROM MyMainDB..ed_mainorg d JOIN Restored..ed_mainorg r

    ON d.PK = r.PK

    WHERE r.Orgname LIKE 'Inc%'

    This assumes you've restored to a database called Restored, that your table has a primary key column called PK, and that there have been no other updates to the table since you made yours. Obviously you'll want to do a SELECT statement first to check that you're going to be updating the correct rows.

    John

  • go dowload Log Rescue from Red Gate (I work for Red Gate). It's free and it will read the logs and give you the reversing statements.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply