BCP in file where 1st line is different

  • Hi there,

    Basically I have a comma delimited file (with 5 fields) that I need to import into SQL Server 2008 using BCP. The first line however is different from the rest in that it only contains one column, this being a record count of the number of records on the file. I intend to use this record count to ensure that the file contains the correct number of records once the import is complete. I can import it in fine (with the help of a format file) when the record count row isn't there, but when it is it (quite expectedly) falls over, even though I remove the reference to the format file.

    Does anyone know the best way of of importing in both the row with the row count and all the records afterwards please?

    Thanks very much

  • Try running it twice, once with format file and -F 2 (for the data), and once with no format file (or different format file) and -F 1 -L 1 for the row counts.

    Different target tables obviously, & assuming that your format file is for the real data, not the row counts.

    Cheers

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

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