It's a good day. Bro.
We will deal with the problem of "invalid byte sequence for encoding "UTF8" when using BCP commands in MSSQL.
🎯 Cause of error
Encoding issues for a character
ex) 0xba
🎯 Solution
When writing the bcp command, enter the -C 65001 option.
bcp "SELECT * FROM test" queryout "E:\test.csv" -S 192.168.0.1,1433 -U test -P 1234 -E -c -C 65001
If your MSSQL version is low, you won't be able to use that option.
-> Code page 65001(UTF8) does not support for SQL Server 2012 (damn..)
-> You can change the encoding in Windows Notepad.
In my experience, this is the simplest way.
블로그 방문해주셔서 감사합니다.
도움이 되셨으면 '좋아요'를 눌러주세요!
추가로 질문사항이 있으면 댓글 남겨주세요 :)