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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Server 2005 & Chinese support

Author  Topic 

medtech26
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 16:22:01
Hello,

I saw lots of issues with SQL and Chinese while searching for a solution but didn't found anything like this:

I have a word table with words in differ. languages and recently I added Chinese to the list, [word_table] looks like this-

id - int
word - nvarchar (200)

When using SQL Server Management Studio to open the table I can see the Chinese characters there as they suppose to be, however, when running a simple query for a Chinese character I get nothing ... ?
SELECT     id, word
FROM word_table
WHERE (word LIKE '?%')

Two things to consider, 1. There is a word record holding the Chinese character in the query, I actually copied it from the table. 2. Well, I did got some records as a result for the above query hoever those records had a question mark as the word, it was wrong data to begin with and was removed.

Any idea what's going on?

Thanks in advance.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-16 : 16:50:50
Not quite following you. ARe you saying you actually used a <question mark> (?) in your criteria?

or you did something like
where work like '?%' --(hopefully this prints correctly)

Does your work START with your character or just contains it. You may need N'%?%'

or even this:
where work like N'%' + nchar(19993) + '%'


EDIT:
Ok I see in my browswer I see a <question mark> for your example as well as mine. Try using the unicode prefix N'' also try the nchar() thing.


Be One with the Optimizer
TG
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 16:56:29
It was suppose to be a Chinese latter/word, for some reason it was converted to '?' after I post the question.

Let's try this '?' or this '%E5%B0%8F'
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 16:59:38
On preview mode it shows the Chinese char/word but not after posting the response ...

Anyway, I'm searching for the Chinese word and not question mark! Have no idea why it's getting converted but this is prob the reason it does not work and brings all records with question mark instead.
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 17:03:04
It worked with N'?%', THANKS.

Now I jest need to figure out why?

EDIT: Just to make it clear, all of my files, application, declarations, db, etc. configured to work with unicode, so, why do I have to redefine the prefix N?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-16 : 17:54:22
I guess it isn't smart enough to know that when comparing a literal string with an nvarchar column that it should treat the literal as unicode. That should probably be explicit anyway. When searching for unicode you need to specifiy a unicode string (N'something')

Be One with the Optimizer
TG
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 17:58:05
Gotcha, thanks.
Go to Top of Page
   

- Advertisement -