SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Chinese letters in XML data type(MSSQL)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tlallo
Starting Member

South Africa
3 Posts

Posted - 02/21/2013 :  06:39:33  Show Profile  Reply with Quote
Hi,

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

bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

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

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

--
Chandu

Edited by - bandi on 02/21/2013 07:25:37
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

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

--
Chandu
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3760 Posts

Posted - 02/21/2013 :  08:27:13  Show Profile  Reply with Quote
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

South Africa
3 Posts

Posted - 02/22/2013 :  03:25:42  Show Profile  Reply with Quote
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


Edited by - tlallo on 02/22/2013 03:27:37
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

Posted - 02/22/2013 :  04:12:53  Show Profile  Reply with Quote
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

Edited by - bandi on 02/22/2013 04:15:25
Go to Top of Page

tlallo
Starting Member

South Africa
3 Posts

Posted - 02/22/2013 :  04:59:05  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2224 Posts

Posted - 02/22/2013 :  05:03:48  Show Profile  Reply with Quote
Welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000