?
Solved

unicode comparison

Posted on 2004-07-30
10
Medium Priority
?
326 Views
Last Modified: 2010-05-19
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
0
Comment
Question by:Lalibela
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 12

Expert Comment

by:ill
ID: 11677536
how does N'unicodeencodedString' you are passing looks like?
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 11677872
Please post your code
0
 
LVL 9

Expert Comment

by:rherguth
ID: 11679619
fieldname must be defined as an NCHAR or NVARCHAR, otherwise you'll need to convert the fieldname to unicode
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Lalibela
ID: 11683103
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
 
LVL 9

Expert Comment

by:rherguth
ID: 11688508
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
 

Author Comment

by:Lalibela
ID: 11691126
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
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 11793329
use LIKE instead of = . LIKE is UNICODE-aware. = is not. I.e.

SELECT * FROM tblName where fieldName LIKE N'unicodeencodedString'
0
 

Author Comment

by:Lalibela
ID: 11919912
Hello,

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

Thanks,

:14:15
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11949322
PAQed, with points refunded (50)

Netminder
Site Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question