Export to CSV

  • Hi,

     

    i am trying to export a table into csv, and it should be comma delimited with doublequotes around each value like this:

    "value1","value2","value3"

    this works fine, but one of the columns includes doublequotes as part of the value, so when its exported to csv, it breaks it into multiple columns. Anyone knows the best way to handle this so that its not splitting it up into multiple columns?

     

     

     

  • Jenny77 wrote:

    Hi,

    i am trying to export a table into csv, and it should be comma delimited with doublequotes around each value like this:

    "value1","value2","value3"

    this works fine, but one of the columns includes doublequotes as part of the value, so when its exported to csv, it breaks it into multiple columns. Anyone knows the best way to handle this so that its not splitting it up into multiple columns?

    Yes.  It's part of the "standard" for proper "CSV" creation (Google for it).  You have to double up on embedded quotes to "escape" them properly.

    --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)

  • What have you tried?  As I recall SSMS export will not properly escape the text.  I'm pretty sure tho SSIS csv export does.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

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

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