How to undo a SQL Server UPDATE query?

前端 未结 5 1751
旧巷少年郎
旧巷少年郎 2021-02-03 21:22

In SQL Server Management Studio, I did the query below.
Unfortunately, I forgot to uncomment the WHERE clause.
1647 rows were updated instead of 4.

5条回答
  •  不思量自难忘°
    2021-02-03 21:56

    If you already have a full backup from your database, fortunately, you have an option in SQL Management Studio. In this case, you can use the following steps:

    1. Right click on database -> Tasks -> Restore -> Database.

    2. In General tab, click on Timeline -> select Specific date and time option.

    3. Move the timeline slider to before update command time -> click OK.

    4. In the destination database name, type a new name.

    5. In the Files tab, check in Reallocate all files to folder and then select a new path to save your recovered database.

    6. In the options tab, check in Overwrite ... and remove Take tail-log... check option.

    7. Finally, click on OK and wait until the recovery process is over.

    I have used this method myself in an operational database and it was very useful.

提交回复
热议问题