SQL Server 2005 Express and BCP

  • Greetings.

    I have been working with BCP to import a csv file into a SQL Server 2005 Express database table.  I'm using a non-xml format file.  I have one extra field in the database table that is not in the csv file.  It is the last field in the table, it is an identity field and is the primary key. 

    I have been struggling with the end of row terminators and getting it to import all of the records right.  Without getting into the history, I have gotten to the point where I can get BCP to import ALL of the records into the table without fail.  The file I am working with right now has 126,000 records in it and both from a command prompt and my stored procedure BCP and my newest format file import all records just fine.

    So, where is the problem you ask?  I get an "Unexpected EOF" error message every time BCP runs, even though it imports all of the records.  I am running BCP from a stored procedure called from an .aspx page and am using an output.txt file and an errors.txt file generated by BCP to provide the results of the import action.  It's frustrating because even though all records are getting imported I still get the EOF error message which implies something went wrong when it really didn't.

    Any thoughts or suggestions?  I've also tried everything out with a very short csv file with only 3 records in it of simple bogus text data that obviously has no flaws or weird data in it and I get the same results...all 3 rows are imported and I STILL get an unexpected EOF error message.

    Thanks in advance,

    jsparks

  • Do you have a newline after the last line of your datafile? If so, remove it.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Thanks.

    As far as I can tell there is not a "new" line or any blank lines at the end of the .csv file.  I just tried removing the end-of-row delimiter from the last line of my text .csv file that only has 3 rows in it, and it only imported the first 2 rows.  It skipped the last and gave the "Unexpected EOF" error message.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply