Sql server 2005 xml Chinese character update request

I am trying to update a tag value with Chinese characters. However, it does not add Chinese characters. Instead, it adds "???", for example update table set col.modify ("replace the value (/ tag / text ()) [1] with" 我 "'), where .. Any help is much appreciated

thanks Ben

+3
source share
2 answers

For international characters like this, you usually want to use N'this - this is my data to designate it as unicode / nchar. Otherwise, it is considered char, and I assume that db sorting cannot support the characters you send. Try to just do

select 'my chars'

and see if all the question marks remain, I would suggest so.

EDIT is an example confirming my suggestions:

declare @x xml
set @x = N'<tag>abc</tag>'
set @x.modify (N'replace value of (/tag/text())[1] with "我"') 
select @x

I see a character when I select xml, and I checked that before and after the character 0x1162 (proves that the data is not corrupted).

+4
source

Do you use Unicode strings? They start with capital N, for example:

update yourtable 
set yourvalue = N'your chinese characters' 
where id = yourid
+2
source

Source: https://habr.com/ru/post/1707801/


All Articles