Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Chinese letters in XML data type(MSSQL)

Author  Topic 

tlallo
Starting Member

3 Posts

Posted - 2013-02-21 : 06:39:33
Hi,

Can someone please help...I 'm trying to insert Chinese character in column with a data type xml.

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-21 : 07:24:12
DECLARE @tab1 TABLE( col xml)
INSERT INTO @tab1 VALUES( N'?')
SELECT * FROM @tab1

? refers any chinese character ( You can replace ? with chinese character)

--
Chandu
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-21 : 07:26:31
Link for chinese characters list
http://www.chinese-tools.com/learn/characters/list.html

--
Chandu
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-02-21 : 08:27:13
To add to what Chandu said: XML in SQL supports unicode characters, so you should not have to do anything special to insert Chinese characters. Are you having any difficulties? If you are, it may be because your OS does not have support for it, or because you are using non-unicode strings somewhere along the way (e.g., you should be using NVARCHAR instead of VARCHAR).
Go to Top of Page

tlallo
Starting Member

3 Posts

Posted - 2013-02-22 : 03:25:42
Hi Bandi,

Thanks for the respond, it did work but my issue is when i'm inserting the chinese in an xml like the following:

UPDATE [Table_name] SET [Col_xml] =
'<?xml version="1.0" encoding="UTF-8"?>
<book>
<person>
<first>'Chinese letters'</first>
<last>Pai</last>
<age>22</age>
</person>
</book>'


When executing the select on the table_name i see <first>??</first> instead of 'Chinese letters'









quote:
Originally posted by bandi

DECLARE @tab1 TABLE( col xml)
INSERT INTO @tab1 VALUES( N'?')
SELECT * FROM @tab1

? refers any chinese character ( You can replace ? with chinese character)

--
Chandu

Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-22 : 04:12:53
DECLARE @EDetails TABLE ( NAME xml )
INSERT INTO @EDetails VALUES(N'?')

UPDATE @EDetails
SET NAME = N'<book>
<person>
<first>???? ÓPCM üñ ¿¡</first>
<last>Pai</last>
<age>22</age>
</person>
</book>'

select * from @EDetails


-- Another example
declare @x TABLE(col xml )
INSERT INTO @x VALUES( N'<tag>abc</tag>')
UPDATE @x set col.modify (N'replace value of (/tag/text())[1] with "?"')
select * FROM @x

--
Chandu
Go to Top of Page

tlallo
Starting Member

3 Posts

Posted - 2013-02-22 : 04:59:05
Yes!!!! it is working....thanks




quote:
Originally posted by bandi

DECLARE @EDetails TABLE ( NAME xml )
INSERT INTO @EDetails VALUES(N'?')

UPDATE @EDetails
SET NAME = N'<book>
<person>
<first>???? ÓPCM üñ ¿¡</first>
<last>Pai</last>
<age>22</age>
</person>
</book>'

select * from @EDetails


-- Another example
declare @x TABLE(col xml )
INSERT INTO @x VALUES( N'<tag>abc</tag>')
UPDATE @x set col.modify (N'replace value of (/tag/text())[1] with "?"')
select * FROM @x

--
Chandu


Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-22 : 05:03:48
Welcome

--
Chandu
Go to Top of Page
   

- Advertisement -