Is it possible to have SQL Server convert collation to UTF-8 / UTF-16

ぃ、小莉子 提交于 2019-12-05 01:10:09

4 months on, I finally found the answer to my problem. Turns out it had nothing to do with the FreeTDS driver, or the database collation:

It was pyodbc's connect function, which apparently requires a flag; unicode_results=True

Posted here to help other unfortunate soules doomed to wander aimlessly in the dark, looking for a clue.

sbiz

It seems that SQL does not support UTF-8 (see here) but you can try changing the collation in the select like:

SELECT Account COLLATE SQL_Latin1_General_CP1_CI_AS
from Data

You can also strip the accents using this solution: How to remove accents and all chars <> a..z in sql-server?

Another solution could be casting your column to nvarchar

SELECT cast (Account as nvarchar) as NewAccount 
from Data

where Account is varchar on your initial table.

If for example you try:

SELECT cast(cast(N'ţ' as varchar) as nvarchar)

the end result will be "ţ"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!