是否可以从虚拟驱动器恢复 SQL Server 数据库?
在 SQL Server Management Studio 中,如果我尝试使用以下命令从备份文件还原数据库:
RESTORE DATABASE somedatabase FROM DISK = '<virtual disk>:\<path>\<backup file>';
我会收到“文件未找到”错误。我正在使用“subst”命令创建。但如果我替换为物理磁盘和完整路径,该命令就可以正常工作。
有没有办法从以虚拟磁盘开头的路径恢复数据库?如果是这样,那是什么?如果没有,我该如何解决这个问题?
顺便说一句,首先使用虚拟磁盘的原因是将脚本与开发环境之间的差异隔离开来(我正在尝试开发一个 MSBuild 脚本来自动创建本地数据库以进行测试。)
In SQL Server Management Studio, if I attempt to restore a database from a backup file with a command like:
RESTORE DATABASE somedatabase FROM DISK = '<virtual disk>:\<path>\<backup file>';
I get a "file not found" error. I'm creating with the "subst" command. But if I replace with a physical disk and with the complete path, the command works just fine.
Is there any way at all to restore a database from a path that starts with a virtual disk? If so, what is it? If not, how might I work around this issue?
As an aside, the reason for using virtual disks in the first place was to insulate the script from differences across development environments (I'm trying to develop an MSBuild script to automate the creation of local databases for testing.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实证明,SQL Server 不支持此功能(不幸的是)。
不久前,我从与我们合作的一位微软顾问那里得到了这个答案。
As it turns out, this capability isn't supported in SQL Server (unfortunately).
I got this answer from a Microsoft consultant we're working with just a little while ago.
如果您可以在安装了 SQL Server 的同一操作系统实例中浏览到 explorer 或 cmd.exe 中的文件,则该文件应该对 SQL Server 可见。
If you can browse to the file in explorer or cmd.exe from the same OS instance where SQL Server is installed, then it should be visible to SQL Server.
驱动器号还需要从运行服务器引擎的帐户中可见。
您对虚拟磁盘使用什么机制?
The drive letter also needs to be visible from the account which the server engine is running under.
What mechanism are you using for the virtual disk?