从同一服务器上的另一个数据库的备份创建新数据库? [英] Creating new database from a backup of another Database on the same server?

查看:247
本文介绍了从同一服务器上的另一个数据库的备份创建新数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从同一服务器上的数据库的旧备份创建一个新的数据库。
当使用 SQL server management studio 并尝试从备份还原到新的数据库时,我收到此错误

  System.Data.SqlClient.SqlError:备份集保存数据库
的备份,而不是现有的test数据库。 (Microsoft.SqlServer.Smo)

googling之后我发现这段代码

  RESTORE DATABASE myDB 

FROM DISK ='C:\myDB.bak'

WITH MOVE'myDB_Data'TO'C:\DATA\myDB.mdf',

MOVE'myDB_Log'TO'C:\DATA\myDB_log.mdf'
GO

我想知道move语句会不会影响备份从那台服务器上来的数据库? p>

感谢您的帮助。

解决方案

这个。




  • 首先创建一个空目标数据库。

  • 然后,在SQL Server Management Studio向导,查找覆盖目标数据库的选项。它位于选项标签中,称为覆盖现有数据库(使用REPLACE)

  • 请记住在文件页面中选择目标文件。



您可以在向导左侧(常规,文件,选项)更改选项卡


I am trying to create a new database from an old backup of database on the same server. When using SQL server management studio and trying to restore to the new DB from the backup I get this error

System.Data.SqlClient.SqlError: The backup set holds a backup of a database 
other than the existing 'test' database. (Microsoft.SqlServer.Smo)

after googling around I found this piece of code

    RESTORE DATABASE myDB

 FROM DISK = 'C:\myDB.bak'

 WITH MOVE 'myDB_Data' TO 'C:\DATA\myDB.mdf',

MOVE 'myDB_Log' TO 'C:\DATA\myDB_log.mdf'
GO

I was wondering will the move statements mess with the database that the backup came from on that server?

Thanks, all help appreciated.

解决方案

I think that is more easy that this.

  • First create a blank target database.
  • Then, in "SQL Server Management Studio" restore wizard, look for the option to overwrite target database. It is in the 'Options' tab and is called 'Overwrite the existing database (WITH REPLACE)'. Check it.
  • Remember to select target files in 'Files' page.

You can change 'tabs' at left side of the wizard (General, Files, Options)

这篇关于从同一服务器上的另一个数据库的备份创建新数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆