SQL Server returns question mark for some unicode chars [duplicate]

狂风中的少年 提交于 2021-02-10 06:20:10

问题


In a nvarchar(512) field if i store unicode chars like this:

UPDATE MYTABLE SET UNICODEFIELD = 'TレEホSᅯTル'

when i query it i get

T?E?S?T?

It looks like the "unusual" chars are not considered as unicode, i would expect the "?" behavior in case of varchar, while with nvarchar it should work fine, i am expecting

TレEホSᅯTル

as output, instead of

T?E?S?T?

Does anyone have an idea about this?


回答1:


Because you're using a varchar, not an nvarchar. 'TレEホSᅯTル' = 'T?E?S?T?' as characters like can't be stored in a varchar.

Use a literal nvarchar:

UPDATE MYTABLE SET UNICODEFIELD = N'TレEホSᅯTル';


来源:https://stackoverflow.com/questions/57091882/sql-server-returns-question-mark-for-some-unicode-chars

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