Importing CSV files in sql with Double quotes

  • 1st ever post so apologies if this isn't in the correct forum....

    I have a CSV file that I'm trying to import but every record (not field) is enclosed in double quotes... (sql 2005)

    e.g

    "row1, row2, row3," --header row

    "a,b,c," --Data row

    The data ends up in a table but the data for the 1st record looks like this "a, b, c".

    How do i get rid of the double quotes on import?

    Cheers

    Chris

  • Thanks Stewartc,

    The SSIS route worked fine, its just a pain I have to create a package for every load. I'm guessing there's no way to do this via the import/export wizard?

    I'm a bit of a novice when it comes to the BCP command line stuff, would this automatically exclude the double quotes.

    Thanks for the help.

  • christopher.hawkes (7/13/2010)


    1st ever post so apologies if this isn't in the correct forum....

    I have a CSV file that I'm trying to import but every record (not field) is enclosed in double quotes... (sql 2005)

    e.g

    "row1, row2, row3," --header row

    "a,b,c," --Data row

    The data ends up in a table but the data for the 1st record looks like this "a, b, c".

    How do i get rid of the double quotes on import?

    Cheers

    Chris

    Make a BCP format file using " \ " \ r \ n" (without the spaces I had to use to get this to show up on this forum) as the final delimiter and skip the first " as a single character column that won't be imported using a delimiter of "" because there is no delimiter between the first and second character. See Books Online for how to do such a thing.

    --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 3 posts - 1 through 3 (of 3 total)

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