SQL Server BCP: How to put quotes around all fields?

前端 未结 7 930
星月不相逢
星月不相逢 2021-02-08 22:01

I have this BCP command:

\'bcp DBName..vieter out c:\\test003.txt -c -T /t\"\\\",\\\"\" -S SERVER\'

The output CSV I get does not put quotes ar

7条回答
  •  生来不讨喜
    2021-02-08 22:18

    The actual workable answer, that removes the leading quote, is to :

    A) generate format file with bcp :

    bcp db.schema.tabel format nul -c -x -f file.xml -t"\",\"" -r"\"\r\n" -T -k
    

    B) edit that file to manually copy field 1 to field 0 above, as the first field, set Max_Length=1 and remove the separator and one quot the was in field1

    
    

    The trick works, as you are adding a field (interface to the file) to detect the first seprator, which results in an always null-value, but not add a row (interface for the query output).

提交回复
热议问题