T-SQL 备份数据库命令用于带空格的文件路径?

发布于 2024-11-03 01:06:23 字数 418 浏览 1 评论 0原文

如何编写T-SQL备份数据库命令来指定包含空格的文件? 这是我得到的:

BACKUP DATABASE AMDMetrics TO DISK = 'C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT'

这是我得到的错误:

消息 3201,级别 16,状态 1,第 1 行 无法打开备份设备“C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT”。操作系统错误3(系统找不到指定的路径。)。 消息 3013,16 级,状态 1,第 1 行 备份数据库异常终止。

How do I write a T-SQL backup database command to specify a file containing spaces?
Here is what I have:

BACKUP DATABASE AMDMetrics TO DISK = 'C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT'

And this is the error I get:

Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

看海 2024-11-10 01:06:23

尝试共享您想要的目标文件夹并使用 UNC 路径从服务器备份到本地计算机。

BACKUP DATABASE AMDMetrics 
    TO DISK = '\\YourMachineName\SharedFolderName\AMD_METRICS.DAT'

Try sharing your intended destination folder and using a UNC path to backup from the server to your local machine.

BACKUP DATABASE AMDMetrics 
    TO DISK = '\\YourMachineName\SharedFolderName\AMD_METRICS.DAT'
云淡风轻 2024-11-10 01:06:23

这对我有用,你确定目录正确吗?

backup database master to disk = 'c:\Test Me\master.bak'


Processed 41728 pages for database 'master', file 'master' on file 1.
Processed 5 pages for database 'master', file 'mastlog' on file 1.
BACKUP DATABASE successfully processed 41733 pages 
in 22.911 seconds (14.230 MB/sec).

将其复制并粘贴到资源管理器中,看看是否可以到达 C:\Documents and Settings\daultrd\My Documents\DatabaseBackups

这当然必须是同一台计算机,否则您需要映射驱动器到该位置或使用 UNC 路径

This works for me, are you sure that the directory is correct?

backup database master to disk = 'c:\Test Me\master.bak'


Processed 41728 pages for database 'master', file 'master' on file 1.
Processed 5 pages for database 'master', file 'mastlog' on file 1.
BACKUP DATABASE successfully processed 41733 pages 
in 22.911 seconds (14.230 MB/sec).

copy and paste this into explorer and see if you can get there C:\Documents and Settings\daultrd\My Documents\DatabaseBackups

This of course has to be the same machine, otherwise you need to map a drive to the location or use UNC paths

穿透光 2024-11-10 01:06:23

我也在解决这个问题。

可能是 SQL Server 运行的服务(默认为网络服务)没有指定文件夹的权限。

BACKUP DATABASE master TO DISK = 'master1.bak' WITH INIT

以上应该备份到默认备份文件夹
如果没有问题,那就是所指出的问题。

I was working through this issue as well.

It's possibly that the Service that SQL Server is running under (Network Service by Default) doesn't have permission to the folder specified.

BACKUP DATABASE master TO DISK = 'master1.bak' WITH INIT

The above should backup to the default backup folder
if that works with no problem it'll be the problem stated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文