Using BCP on records with variable lengths

  • I am using BCP with a format file.

    The input file contains fixed length fields on each record.

    Sometimes the trailing fields on a record are missing because they do not contain any values. This causes the record length be shorter than expected.

    This is confusing BCP into using the next record to fill in the missing fields and causing errors.

    Is there a way to get BCP to skip these trailing fields when they are missing?

    Is there a way to pad a record with spaces so they are all the same length?

    David Bird

  • tough luck. When you need trailing columns that are blank you must at least provide the last comma (csv) or use "" for your char fileds. The only solution is to fix the source data.

    Cheers,


    * Noel

  • While it's a very awkward workaround, if you have no power to get the source data corrected, you could dump the data into a single fixed-length char column, thus padding it, but if you went that route, you might as well do the parsing there instead of through BCP.

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

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