Commas within CSV Data

前端 未结 7 1568
春和景丽
春和景丽 2020-12-01 12:36

I have a CSV file which I am directly importing to a SQL server table. In the CSV file each column is separated by a comma. But my problem is that I have a column \"address\

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 13:09

    Appending a speech mark into the select column on both side works. You must also cast the column as a NVARCVHAR(MAX) to turn this into a string if the column is a TEXT.

    SQLCMD -S DB-SERVER -E -Q "set nocount on; set ansi_warnings off; SELECT '""' + cast ([Column1] as nvarchar(max)) + '""' As TextHere, [Column2] As NormalColumn FROM [Database].[dbo].[Table]" /o output.tmp /s "," -W
    

提交回复
热议问题