unicode comparison

Hello,

I want to compare two an a string which is a unicode in where clause of SQL, like SELECT * FROM tblName where fieldName=N'unicodeencodedString'. The trouble is it always return all the records. Can somebody help me on this?

Lalibela,

:14:15
LalibelaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
NetminderConnect With a Mentor Commented:
PAQed, with points refunded (50)

Netminder
Site Admin
0
 
illCommented:
how does N'unicodeencodedString' you are passing looks like?
0
 
HilaireCommented:
Please post your code
0
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

 
rherguthCommented:
fieldname must be defined as an NCHAR or NVARCHAR, otherwise you'll need to convert the fieldname to unicode
0
 
LalibelaAuthor Commented:
Hello,

I have defined field name with type NVARCHAR and the data is passed from jsp page encoded with UTF-8. I want to use it for checking user privilege. Here is the SQL:

SELECT * FROM tblUser where userName=N'ላሊበላ'; that is all.


Lalibela,

:14:15



0
 
rherguthCommented:
Is the username data URI Encoded in your table?

The SQL engine doesn't know how to decode the string, so that could be the problem.  It would be an interesting feature to add, but it's not currently there.  However, if you are storing them encoded, it should work, although it would then be more difficult to produce hman readable reports.  If you're not sure what I'm asking, reply with a sample row of the username field.

If that is the problem, then you should use something like the unescape() method in javascript to convert the encoded string to the original text representation of the username.
0
 
LalibelaAuthor Commented:
Hello,

I have stored the unicode character and retrive it correctly. I use JDBC-ODBC bridge.The problem is with searching. I discovered this,when I change the collation to binary 850_CP it works correctly. Can anybody tell me the default collation for unicode characters other than the ones provided by SQL SERVER? like for languages Ethiopic... I think the collation is the problem.


Thanks,

Lalibela,
:14:15
0
 
Vadim RappCommented:
use LIKE instead of = . LIKE is UNICODE-aware. = is not. I.e.

SELECT * FROM tblName where fieldName LIKE N'unicodeencodedString'
0
 
LalibelaAuthor Commented:
Hello,

I have used like but it does not work. I change the collation and it works fine with me.

Thanks,

:14:15
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.