Solved

unicode comparison

Posted on 2004-07-30
10
325 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 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