我试图恢复我的数据库的SQL Server备份文件,但它抛出一个错误如下:

备份集保存现有数据库以外的数据库的备份

我的数据库是SQL Server 2008,备份文件是2005年的。

会有什么问题呢?


当前回答

我也有同样的问题,但在PS上。我把它留在这里,以防有人试图做同样的事情

Restore-SqlDatabase -ServerInstance "<your instance name>" -Database "<your db name>" -BackupFile "<backup file route>.bak" -ReplaceDatabase

记住使用Set-ExecutionPolicy Unrestricted -Force和import import-module sqlps。完成后,不要忘记将执行策略设置为受限。

其他回答

通常处理.bak文件会让人头疼,一种更直接的方法是使用sqldump文件来传输数据库。

生成要移动或复制的当前数据库的脚本。 选择All Tables,而不是整个数据库。 从选项菜单中选择另存为脚本,然后单击高级按钮并设置以下配置(我正在起诉MSSQL 2016): 现在,在你想导入这些数据的地方,创建一个新数据库,切换到这个新数据库(我的意思是设置为默认值) 最后运行脚本,将导入所有表和数据。

祝你好运。

列表项

我通过另一种方式完成工作,使用生成脚本。这对我来说确实有用,因为由于同样的错误,Backup-Restore没有帮助解决这个问题。

简单3步:

1-右键单击数据库→任务→恢复→数据库

2-检查设备作为源,并找到。bak(或压缩。bak)文件

3-在左侧窗格单击选项和:

check覆盖现有数据库。 恢复前进行尾日志备份 关闭到目标数据库的现有连接。

其他选项都是可选的(当然也很重要)!

这帮助我从系统驱动器导入备份文件

Create a database with the same name(preferably) as your .bak file database name Right click the database > Tasks > Restore > Database Under "Source for restore" select "From Device" Select the .bak file selecting the path from the system Select the check box for the database in the list box below Under "Select a Page" on the right Select "Options" Select the checkbox labeled "Preserve the replication settings(WITH KEEP_REPLICATION) Select the checkbox for Overwrite the existing database(WITH REPLACE) Now Go back to the General page and click OK to restore the database...

而不是点击恢复数据库点击恢复文件和文件组..

这在我的SQL服务器上工作