Solved

unicode comparison

Posted on 2004-07-30
10
322 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article describes some very basic things about SQL Server filegroups.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

809 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