2

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?

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • this qusetion is marked as duplcite, but it is not a duplicate, the other qusetion is about the N prefix, the answer here is about it. I think it is better to leave it as a separate question because it could be useful. – UnDiUdin Jul 19 '19 at 09:51

1 Answers1

2

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ル';
Thom A
  • 88,727
  • 11
  • 45
  • 75
  • Yes. simple as that. Up to now i always ignored that "N" since i used to store unicode data through copmonents that were handling that for me. Thanks. – UnDiUdin Jul 18 '19 at 10:02