批量上传:“意外的文件结尾”在新服务器上
我正在尝试在我们的 sql 数据库中的一个表中进行批量上传。当我们将数据库放在不同的服务器上时,这个查询之前运行良好,但现在在新服务器上我收到错误。 这是我所拥有的: sql 批量导入查询:
BULK
INSERT NewProducts
FROM 'c:\newproducts.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
我收到的错误是:
Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
感谢您提前提供的任何帮助。
I am trying to do a bulk upload in one table in our sql database. This query was running good before, when we had the database on different server, but now on the new server I am getting an error.
Here is all I have:
sql bulk import query:
BULK
INSERT NewProducts
FROM 'c:\newproducts.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
And the errors I am getting are:
Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
Thanks for any help in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于遇到此问题并寻求答案的其他人来说,当 CSV 文件中的列数与要批量插入的表的列数不匹配时,也会发生此错误。
For anybody else who comes across this question looking for an answer, this error also happens when the number of columns in your CSV file don't match the columns of the table you're doing the bulk insert into.
我以前遇到过这种情况,需要注意以下几点:
\n
而不是\r\n
如果您执行了所有这三个操作,但仍然收到错误,请告诉我。
I've encountered this before and there are a few things to look for:
\n
and not\r\n
If you do all three of these and are still getting the error let me know.
就我而言,我尝试访问的文件位于 SQL Sever 进程无权访问的目录中。我将平面文件移至 SQL 可以访问的目录,此错误已解决。
In my case the file I was trying to access was in a directory that the SQL Sever process did not have access to. I moved my flat files to a directory SQL had access to and this error was resolved.