Importing txt file with header using Bulk Insert

  • I am trying to import a text file with a 2 line header using Bulk Insert and/or bcp. I can't seem to get the first row of data to import.

    If I delete the 2 row header using notepad, I get all the data rows.

    Can you help?

  • Actually... no... not using Bulk Insert or BCP... they both require the headers to have the same number of delimiters as the "body" of the file even when you tell it to skip lines. It's the worst oversight the makers of BCP ever came up with.

    One way to get around it is to make a little VB Script that copies all but the header line(s) to another file and then import that other file.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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