从 SQL Server 2000 恢复已删除的行

发布于 2024-12-07 11:22:41 字数 206 浏览 2 评论 0原文

脚本使用以下查询意外地从数据库中删除了几行:

DELETE FROM that_table WHERE id IN (100, 101, 102)

同时添加了更多行。有没有办法让我将三行恢复到同一个表(或者可能是另一个数据库/表)中?我不想恢复数据库,因为这意味着我会丢失该查询后添加/更新的所有数据。手动输入缺失的行是一种选择。

A script accidentally deleted few rows from the database with the following query:

DELETE FROM that_table WHERE id IN (100, 101, 102)

More rows have been added in the mean time. Is there a way for me to recover the three rows into the same table (or perhaps another database/table)? I do not want to restore the database as if this means I lose all data added/updated after that query. Hand entering the missing rows is an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青柠芒果 2024-12-14 11:22:41

您可以使用 ApexSQL Log,这是一种 SQL Server 审核和恢复工具,可以从数据库事务日志中读取信息并为 DML 和 DDL 操作提供撤消 T-SQL 脚本。

免责声明:我在 ApexSQL 担任产品支持工程师

You can use ApexSQL Log, a SQL Server auditing and recovery tool which reads information from database transaction logs and provides undo T-SQL scripts both for DML and DDL operations.

Disclaimer: I work as a Product Support Engineer at ApexSQL

懷念過去 2024-12-14 11:22:41

当您使用 SQL Server 2000 时,您可能会幸运地获得免费的 Redgate SQL Log Rescue Tool 适用于此版本。

As you are on SQL Server 2000 you may be in luck as the free Redgate SQL Log Rescue Tool works against this version.

半仙 2024-12-14 11:22:41

幸运的是,我有一个备份,因此我使用此处描述的过程在同一服务器上但在新数据库下恢复备份:

将完整备份恢复到同一服务器上的新数据库

在新数据库中恢复数据库备份后,我找到了行并将其插入:

INSERT INTO that_database..that_table
SELECT * FROM copy_database..that_table WHERE id IN (100, 101, 102)

以上查询没有立即运行,我必须启用身份插入并暂时禁用一些约束。

Luckily I had a backup so I used the procedure described here to restore the backup on the same server but under a new database:

Restoring a Complete Backup to a New Database on the Same Server

After the database backup was restored in a new database, I located the rows and inserted them:

INSERT INTO that_database..that_table
SELECT * FROM copy_database..that_table WHERE id IN (100, 101, 102)

The above query did not run out of the box, I had to enable identity insert and disable a couple of constraints temporarily.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文