由于无法打开文件,因此无法批量加载。操作系统错误代码3 [英] Cannot bulk load because the file could not be opened. Operating System Error Code 3

查看:929
本文介绍了由于无法打开文件,因此无法批量加载。操作系统错误代码3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将存储过程设置为SQL Server代理作业,这给了我以下错误,

I'm trying to set up a Stored Procedure as a SQL Server Agent Job and it's giving me the following error,

由于文件 P :\file.csv无法打开。操作系统错误代码3(未能为此错误检索文本。原因:15105)。 [SQLSTATE 42000](错误4861)

Cannot bulk load because the file "P:\file.csv" could not be opened. Operating system error code 3(failed to retrieve text for this error. Reason: 15105). [SQLSTATE 42000] (Error 4861)

有趣的是,当我手动执行存储过程时,它的运行情况还不错。

Funny thing is the Stored Procedure works just fine when I execute it manually.

驱动器P:是Windows SQL Server上LINUX通过Samba Share的共享驱动器,它是通过执行以下命令来设置的,

The drive P: is a shared drive on Windows SQL Server from LINUX via Samba Share and it was set up by executing the following command,

EXEC xp_cmdshell'net use P: \lnxusanfsd01\Data密码/ user:用户名/ Persistent:是'

EXEC xp_cmdshell 'net use P: "\lnxusanfsd01\Data" Password /user:username /Persistent:Yes'

任何帮助

推荐答案

我不知道您是否解决了这个问题,但是如果实例是在本地,必须检查访问文件的权限,但是,如果要从计算机访问服务器(远程访问),则必须指定服务器中的路径,这意味着将文件包括在服务器目录中,这样可以解决该问题。我的案子

I dont know if you solved this issue, but i had same issue, if the instance is local you must check the permission to access the file, but if you are accessing from your computer to a server (remote access) you have to specify the path in the server, so that means to include the file in a server directory, that solved my case

示例:

BULK INSERT Table
FROM 'C:\bulk\usuarios_prueba.csv' -- This is server path not local
WITH 
  (
     FIELDTERMINATOR =',',
     ROWTERMINATOR ='\n'
  );

这篇关于由于无法打开文件,因此无法批量加载。操作系统错误代码3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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