Ctrl+Shift+B

Compilations by Steve Majewski
posts - 208, comments - 140, trackbacks - 2

My Links

News


The ideas contained herein are mine and mine alone, and do not reflect the beliefs of my employer, family, friends, faith, or society in general. Reader discretion advised.


Memberships

Article Categories

Archives

Post Categories

Resources

Blogroll

Podcasts

Miscellaneous

Debugging: Unexpected EOF encountered in BCP data-file

I ran across an issue recently with SQL Server's Bulk Copy (BCP) utility. The command-line based utility is designed for copying large amounts of data to and from data files. It is actually used behind the scenes for the BULK INSERT command.

We decided to use BCP on a particularly large data import because .NET is much slower at reading files. Our goal was to invoke BCP in a separate thread to get the data from a flat file into the database for later processing. The process had been working at one point, but refused to work at all now.

The debug process led we us to a rather misleading error message "Unexpected EOF encountered in BCP data-file" and no records would be processed at all. We performed all the typical checks of the source file like looking for special characters in a HEX editor and trimming the file to just one record. Nothing was working.

As it turns out, the fields we were importing did not match up to the fields in the destination table. An identity column had been added as the first column in the table and BCP was trying to put a value into it. All it took was to add a format file (see SQL Server Books Online for details) to the import process so that BCP would know where everything is supposed to go.

Needless to say, the error message being returned by BCP was a bit on the obscure side. I would've expected something more like a data type mismatch since it was trying to put a string into a numeric field. Oh, well. It's not like obscure messages from command-line utilities are anything new. Live. Learn. Pass it on. Let me know if it worked for you.

Print | posted on Monday, October 17, 2005 11:35 AM

Powered by: