Unexpected EOF encountered in BCP data-file

此生再无相见时 提交于 2019-12-02 17:43:32

问题


I was trying copy data from a table to another table in another database using bcp.

First a format file was created using

!! bcp dbName1.dbo.tableName1 format nul  -S serverName1 -T -f D:\tableName1_fmt.txt -n

Then the data file was created using

!! bcp dbName1.dbo.tableName1 out D:\tableName1.txt  -S  serverName1 -T -c

Now I tried to import the data-file to another table in another database present in another server using the format file

!! bcp dbName2.dbo.tableName2 in D:\tableName1.txt -f D:\tableName1_fmt.txt  -S ServerName2 -T -E 

Then the following error was generated

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 13 for SQL Server]Unexpected EOF encountered in BCP data-file

0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total     : 1    

I figured out the problem. But it was a different case from the existing ones in Stackoverflow.

So I am writing my solution in case someone encounter with the same may benefit.


回答1:


The problem was with format specifiers (-c, -n) while creating Format-file and Data-file.

The format specifier for Format File (-n) and Data File (-c) was different.

When I changed format specifier of both to either -c or -n, the import statement worked.

Since retaining datatype of columns was important for my purpose, -n was used for format file and data file



来源:https://stackoverflow.com/questions/52295174/unexpected-eof-encountered-in-bcp-data-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!