How to undo a SQL Server UPDATE query?

前端 未结 5 1749
旧巷少年郎
旧巷少年郎 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

    Considering that you already have a full backup I’d just restore that backup into separate database and migrate the data from there.

    If your data has changed after the latest backup then what you recover all data that way but you can try to recover that by reading transaction log.

    If your database was in full recovery mode than transaction log has enough details to recover updates to your data after the latest backup.

    You might want to try with DBCC LOG, fn_log functions or with third party log reader such as ApexSQL Log

    Unfortunately there is no easy way to read transaction log because MS doesn’t provide documentation for this and stores the data in its proprietary format.

提交回复
热议问题