Accented characters not correctly imported with BULK INSERT

前端 未结 4 2011
遥遥无期
遥遥无期 2021-01-15 05:22

I am importing a source CSV file, I don\'t know the source encoding and I can only see either � (ANSI encoding) or (UTF8-without-BOM encoding)

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 05:27

    I've done it! After all these years and we were all looking in the wrong place. No work needed no rewriting scripts...

    The problem lies with SSMS... if you "New Query" by right-clicking on "Queries" you get to rename the file but not create it that is done for you...

    But... if you "Ctrl+N" you get a new query window to edit but no file is created... So you save it yourself and choose encoding on the save button... towards the bottom of the list you'll find UTF-8(without signature) codepage 65001

    And that is it...

    script after script open a new query window with "ctrl+N" copy and paste from an existing query and save as directed above. And as if by magic it works

    If like me you have tables in Excel... parse the table writing the output to the 1st column of a new workbook with 1 sheet in it and then saveas and choose utf-8 encoding

    Speed things up with a template file containing a comment "-- utf-8" something like that. save it as utf-8 and use a file listing of *.sql pasted into excel to concatenate a list of =concatenate("ren templatefile.txt ", char(34), a1, char(34)) in b1 and drop it down

    After all these years of manual solutions I am literally sweating with excitement at the discovery. Thank you for getting me so upset

提交回复
热议问题