comma delimited file, header has a different number of columns than the body

  • I haven't seen this before. I have a request for a comma delimited file where the header has a different number of columns than the body.

    File1,1234,A,CompanyZYX

    A,1

    B,3

    C,5

    Is this common? Is this bad design?

    Can this be done with DTS or SSIS or should I look at concatenating the columns with commas in my select?

    SELECT column1 + ',' + column2 + ',' column3 + ',' + column4

    UNION

    SELECT column1 + ',' + column2

  • It's all TOO common and, yes, it's a bad practice. That "extra" information should usually be a part of the file name.

    The method you've chosen isn't bad for your requirements, though.

    --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)
    Intro to Tally Tables and Functions

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

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