Undo table updates in SQL Server 2008

早过忘川 提交于 2019-12-11 19:44:03

问题


I updated a table in my SQL Server 2008 by accident, I was updating a table from another by copying cell by cell, but I have overwritten the original table. Is there a way that I can restore my table contents as it was?


回答1:


This tool says it can do it, a bit pricey though. There is a trial period, maybe that will be long enough to get your data back:

http://www.apexsql.com/sql_tools_log.asp?_kk=log%20explorer&_kt=49fb8026-ca7c-4c5e-bb06-99ee95393472&gclid=CPWP48T3i6ICFY1a2godtTS7UQ




回答2:


No. If you commited the transaction, the only way to restore the original table is by getting it from your latest backup.




回答3:


if you have only a backup then restore that to another database and move just the table over (this way no other tables will be affected). If you have also transaction log backups then you can also do a point in time restore




回答4:


I've heard that there are some tools that might be able to undo certain actions in certain circumstances. Here's a link to an interesting article about how to minimize data loss in these circumstances and it includes links to some tools.

You might want to ask this question at ServerFault as well as some sysadmins might know better.




回答5:


Check this link. It shows how to restore values using transaction log

https://www.experts-exchange.com/articles/28199/How-to-recover-deleted-rows-in-SQL-Server.html

The article shows how we can recover deleted data if it happens accidently. We can recover deleted rows if we know the time when data is deleted. We can achieve this goal using LSN ( Log Sequence Numbers ). It shows an example of restoring deleted rows by checking the transaction log with LSN values. For updates use 'LOP_MODIFY_ROW'.

After deleting rows check the log using the following query

Select [Current LSN] LSN], [Transaction ID], Operation, Context, AllocUnitName
FROM
fn_dblog(NULL, NULL)
WHERE Operation  = 'LOP_DELETE_ROWS'

Based on the transactionID and number of rows affected, filter the result set. Then use RESTORE DATABASE to restore the values from log.

NOTE: It is best to do this restoration as soon as you realize the accidental modification/deletion. The more the operations happening in a database there is high probability that the transaction log values might get overwritten.



来源:https://stackoverflow.com/questions/2984966/undo-table-updates-in-sql-server-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!