SQL Server:强制备份/恢复位置
使用 BACKUP DATABASE 命令在笔记本电脑上复制了 SQL Server Express 数据库的副本,现在我尝试使用 T-SQL 语句将其恢复到另一台计算机上:
RESTORE DATABASE [OurDB]
FROM DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part1.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part2.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part3.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part4.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part5.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part6.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part7.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part8.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part9.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part10.bak'
WITH REPLACE
GO
但是当它尝试恢复我收到错误
消息 5133,级别 16,状态 1,第 1 行
目录查找文件“c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\AppConfig_Data.ndf”失败, 操作系统错误 3(无法检索此错误的文本。 原因:1815)。
还有其他几个,都是类似的错误。问题是 SQL Server 似乎正在尝试将数据库还原到目录 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\
(源计算机上的数据目录)备份是从.
但在新计算机上我想恢复到 SQL Server 数据路径是 C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
如何更改数据中的路径-文件以使其恢复到正确的位置?
Took a copy of a database of SQL Server Express on a laptop using the BACKUP DATABASE
command, now I'm trying to restore it to a different computer using the T-SQL statement:
RESTORE DATABASE [OurDB]
FROM DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part1.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part2.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part3.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part4.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part5.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part6.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part7.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part8.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part9.bak',
DISK = N'C:\Documents and Settings\Sam\Desktop\DBBackup\part10.bak'
WITH REPLACE
GO
But when it tries to restore I get the error
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "c:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\AppConfig_Data.ndf" failed with the
operating system error 3 (failed to retrieve text for this error.
Reason: 1815).
And a couple of others, all similar errors. The problem is it looks like SQL Server is trying to restore the database to the directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\
, the data directory on the source computer the backup was taken from.
But on the new computer I want to restore to the SQL Server data path is C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
How do I change the path in the data-files to get it to restore to the correct location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要向 RESTORE 命令添加附加信息来定义这些位的位置 - 类似于:
You need to add additional info to your RESTORE command to define where those bits should go - something like: