如何在SQL Server中还原到其他数据库? [英] How to restore to a different database in sql server?
问题描述
我一周前有一个 Database1 的备份.备份每周在调度程序中完成,我得到一个.bak
文件.现在,我想弄弄一些数据,因此需要将其还原到另一个数据库- Database2 .
I have a backup of Database1 from a week ago. The backup is done weekly in the scheduler and I get a .bak
file. Now I want to fiddle with some data so I need to restore it to a different database - Database2.
我已经看到以下问题:还原SQL Server数据库中具有不同名称的同一台计算机,建议的步骤是重命名原始数据库,但是由于我不在生产服务器中,因此无法使用该选项.
I have seen this question: Restore SQL Server database in same pc with different name and the recommended step is to rename the original db, but I am out of that option as I am in the production server and I cant really do it.
还有其他方法可以将其还原到Database2
,或者至少如何浏览该.bak文件的数据吗?
Is there any other way of restoring it to Database2
, or atleast, how do I browse through the data of that .bak file?
谢谢.
ps:上述链接的第二个答案看起来很有希望,但它总是以错误终止:
ps: the second answer from the above link looked promising but it keeps terminating with error:
还原文件列表异常终止
Restore Filelist is terminating abnormally
推荐答案
您可以创建一个新的数据库,然后使用还原向导"启用覆盖"选项;或者;
You can create a new db then use the "Restore Wizard" enabling the Overwrite option or;
查看内容;
RESTORE FILELISTONLY FROM DISK='c:\your.bak'
请注意.mdf&的逻辑名称然后从结果中找到.ldf;
note the logical names of the .mdf & .ldf from the results, then;
RESTORE DATABASE MyTempCopy FROM DISK='c:\your.bak'
WITH
MOVE 'LogicalNameForTheMDF' TO 'c:\MyTempCopy.mdf',
MOVE 'LogicalNameForTheLDF' TO 'c:\MyTempCopy_log.ldf'
使用内容your.bak
创建数据库MyTempCopy
.
示例(将名为"creditline"的数据库的备份恢复为"MyTempCopy";
Example (restores a backup of a db called 'creditline' to 'MyTempCopy';
RESTORE FILELISTONLY FROM DISK='e:\mssql\backup\creditline.bak'
>LogicalName
>--------------
>CreditLine
>CreditLine_log
RESTORE DATABASE MyTempCopy FROM DISK='e:\mssql\backup\creditline.bak'
WITH
MOVE 'CreditLine' TO 'e:\mssql\MyTempCopy.mdf',
MOVE 'CreditLine_log' TO 'e:\mssql\MyTempCopy_log.ldf'
>RESTORE DATABASE successfully processed 186 pages in 0.010 seconds (144.970 MB/sec).
这篇关于如何在SQL Server中还原到其他数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!