How to fix the embedded text qualifier issue while exporting data to CSV flat file?

前端 未结 3 1488
[愿得一人]
[愿得一人] 2020-12-13 12:01

RFC 4180:

RFC 4180 defines Common Format and MIME Type for Comma-Separated Values (CSV) Files. One of the requirements of th

3条回答
  •  隐瞒了意图╮
    2020-12-13 12:33

    Often the first and last name is in the same field and formatted (Last, First). This needs to be text qualified if you're using Tasks->Export Data right off the database (not via SSIS where you have more options) and you need to export to CSV as comma-delimited file.

    This will help in your non-null selected fields that need double quoting...

    CASE WHEN NOT PersonName IS NULL AND LEN(PersonName) > 0 THEN QUOTENAME(PersonName, '"') ELSE NULL END as 'PersonName'
    

    Result:

    PersonName

    "COLLINS, ZACKERY E"

提交回复
热议问题