Exporting data from SQL Server Express to CSV (need quoting and escaping)

后端 未结 10 1939
执笔经年
执笔经年 2020-12-05 04:16

I\'ve spent 2 days trying to export a 75,000 row table containing a large text field of user input data from a SQL server installation. This data contains every plain ascii

10条回答
  •  死守一世寂寞
    2020-12-05 05:01

    It can be done! However you have to specifically configure SSMS to use quoted output, because for some daft reason it is not the default.

    In the query window you want to save go to Query -> Query Options...

    Check the box "quote strings containing list separators when saving .csv results".

    enabling quoted csv output

    then

    select 'apple,banana,cookie' as col1,1324 as col2,'one two three' as col3,'a,b,"c",d' as col4
    

    will output

    col1,col2,col3,col4
    "apple,banana,cookie",1324,one two three,"a,b,""c"",d"
    

    which is what we all want.

提交回复
热议问题