不能做BULK INSERT [英] Cannot do BULK INSERT

查看:94
本文介绍了不能做BULK INSERT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SQL Server新手,刚刚开始。我正在尝试做一个BULK INSERT,但它一直给出错误 -



命令是 -



I'm new to SQL Server, just started. I am trying to do a BULK INSERT but it keeps giving the error -

Command is -

BULK INSERT Astronomy_DB.dbo.Messier_Table
FROM 'f:\testdata.cvs'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)





但无论我把文件放在哪里,它总会给我错误:





but it always gives me the error no matter where I put the file:

Msg 4860, Level 16, State 1, Line 1
Cannot bulk load. The file "f:\testdata.cvs" does not exist.





有人可以给我一个线索吗?



Could someone please give me a clue?

推荐答案

只是一个粗略的猜测,但由于SQL Server服务作为一个不是你的帐户运行,它无法访问我认为是网络驱动器。将文件本地复制到服务器并从那里尝试。我愿意这样做。
Just a rough guess, but since the SQL Server service runs as an account that is not YOU, it doesn't have access to what I assume is a network drive. Copy the file locally to the server and try it from there. I'd be willing to be it works.


戴夫,谢谢你的回复。它实际上不是网络驱动器问题 - f:我正在使用的usb拇指驱动器。显然,SQL Server不喜欢.csv文件扩展名。我把它改成了.dat并取得了成功。唯一的另一个问题是,当我保存为.csv时,Excel在每行中添加了额外的逗号。当我删除那些一切都很好!



再次,感谢您的回复。
Dave, thank you for the reply. It was actually not a network drive issue - f: was a usb thumb drive I was using. Apparently SQL Server did not like the .csv file extension. I changed it to .dat and had success. the only other problem was the extra commas that Excel put at the each line when I saved as .csv. When I removed those all was well!

Again, thanks for the response.


您的登录应该有权访问读取文件在F盘上。尝试将文件移动到备用驱动器。



可以替换批量上传(SqlBulkCopy等)。 处理从CSV到SQL Server的BULK数据插入 [ ^ ]提到了其他一些方法。
Your login should have access to read file on the F drive. Trying moving the file to an alternate drive.

There can be alternates to bulk upload (SqlBulkCopy etc.). Handling BULK Data insert from CSV to SQL Server[^] mentions some of these other approaches.


这篇关于不能做BULK INSERT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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