Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BCP In: "Unexpected EOF" error

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I am trying to migrate some of my DataJunction (a conversion tool) conversions over to BCP.

First I imported one of my fixed-format text-files into SQL Server 2005 using DataJunction. Then I generated a BCP XML format file via the command-line. Next I truncated the table, then tried to load the file via BCP command-line:
Code:
bcp MyDatabase.dbo.MyTable In "C:\MyTextFile.txt" -f "C:\My_BCP_Format.xml" -T -SMyServer

I am getting an error stating "Unexpected EOF encountered in BCP data-file".

I doubt this is correct, since DataJunction typically generates an error if there's a rogue EOF in a file. I've also tried several other text-files in the same format but they fail with the same error.

I'm wondering if the datatypes are mismatched somehow (see the create table/format file below).

The only other clue I see in the BCP message is "Network packet size (bytes): 4096". As I recall when the database was set up there were problems with the 2005 install because of the block size chosen or something; could this be the problem?

Here are sample lines from my Create Table statement:
Code:
CREATE TABLE [dbo].[MyTable](
	[Field1] [char](15) NULL,
	[Field2] [char](8) NULL,
	[Field3] [char](7) NULL,
...

and from my format file:
Code:
<BCPFORMAT xmlns="[URL unfurl="true"]http://schemas.microsoft.com/sqlserver/2004/bulkload/format"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance">[/URL]
 <RECORD>
  <FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="15" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="8" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="3" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="7" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
...
 </RECORD>
 <ROW>
  <COLUMN SOURCE="1" NAME="Field1" xsi:type="SQLCHAR"/>
  <COLUMN SOURCE="2" NAME="Field2" xsi:type="SQLCHAR"/>
  <COLUMN SOURCE="3" NAME="Field3" xsi:type="SQLCHAR"/>
...
 </ROW>

Thanks.
 
Nevermind...turns out the format file generated by SQL Server is somewhat useless and incorrect. After manually changing the <RECORD> entries as shown below, it worked fine:

Code:
  <FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="15" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
- to -
  <FIELD ID="1" xsi:type="CharFixed" LENGTH="15"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top