bcp command - microsoft examples do not run - what am I doing wrong?

  • I am attempting to run the examples from Microsoft SQL Server 2005 Books Online for BCP Import:

    Using a Format File to Skip a Table Column

    http://msdn.microsoft.com/en-us/library/ms179250(SQL.90).aspx

    and

    Using a Format File to Skip a Data Field

    http://msdn.microsoft.com/en-us/library/ms187908(SQL.90).aspx

    1) I have created the tables successfully

    2) created the format files using BCP commands listed (manually & by clicking "copy code")

    3) I have edited the format files as prescribed by examples (manually & by clicking "copy code")

    4) I created the data files using notepad and using "copy code" to grab the data and insert into data file. Saved data file as ANSI text

    the following are the results of my efforts:

    C:\>bcp AdventureWorks..myTestSkipCol in c:\myTestSkipCol2.dat -f c:\myTestSkipCol_Default.fmt -c -T

    Warning: -c overrides -f.

    Starting copy...

    SQLState = S1000, NativeError = 0

    Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

    0 rows copied.

    Network packet size (bytes): 4096

    Clock Time (ms.) Total : 1

    and

    C:\>bcp AdventureWorks..myTestSkipField in c:\myTestSkipField-c.dat -f c:\myTestSkipField.fmt -c -T

    Warning: -c overrides -f.

    Starting copy...

    SQLState = S1000, NativeError = 0

    Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

    0 rows copied.

    Network packet size (bytes): 4096

    Clock Time (ms.) Total : 1

    My head is a little bruised from banging my head on the wall trying to get this to work.:crying:

    I am logged in as an administrator, the administrator group and db_Owner permissions.

  • A couple of things. First, the format file that the example creates does not match the data file. The format file has "\t" for the field terminator. \t is tab. You'll want to change that to a "," for a comma separated file. Next, take the -c out of your bcp command. You can see in your warning output that using -c overrides the format file option.

    Change those two things and you should be good to go.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • that worked perfectly, thanks so much for your timely response:w00t:

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

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