BCP数据文件中遇到意外的EOF [英] Unexpected EOF encountered in BCP data-file

查看:626
本文介绍了BCP数据文件中遇到意外的EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用bcp将数据从一个表复制到另一个数据库中的另一个表.

首先使用以下格式创建格式文件

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

然后使用以下文件创建数据文件

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

现在,我尝试使用格式文件将数据文件导入另一台服务器中另一个数据库中的另一个表中

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

然后产生了以下错误

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    

我发现了问题所在.但这与Stackoverflow中的现有情况不同.

因此,如果有人遇到相同的问题可能会受益,那么我正在写我的解决方案.

解决方案

问题在于创建格式文件和数据文件时使用格式说明符(-c-n)./p>

格式文件(-n)和数据文件(-c)的格式说明符不同.

当我将两者的格式说明符都更改为-c-n时,导入语句起作用.

由于保留列的数据类型对我而言很重要,因此-n用于格式文件和数据文件

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.

解决方案

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

这篇关于BCP数据文件中遇到意外的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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