SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Unicode Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Nick
Posting Yak Master

155 Posts

Posted - 01/26/2004 :  12:08:44  Show Profile  Visit Nick's Homepage  Reply with Quote
Hello-

I'm having a problem with a simple query, and I'm really not sure why. I have a field defined as nvarchar. When I do the following query in the query analyzer:

select top 1 tbLast from tblPeople

I get the following result

Ñáðôïðïýëïõ

Now if I do this query:

select top 1 tbLast from tblPeople
WHERE tbLast LIKE '%Ñáðôïðïýëïõ%'

Nothing gets returned. I would expect I would get the same result as above. Is there something I'm missing when working with Unicode?

Thanks-
Nick

(Note, the result did not render properly in the forum, but for reference purposes it contains Greek characters.

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 01/26/2004 :  12:14:50  Show Profile  Visit nr's Homepage  Reply with Quote
try
select top 1 tbLast from tblPeople
WHERE tbLast LIKE N'%Ñáðôïðïýëïõ%'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 01/26/2004 :  12:14:52  Show Profile  Reply with Quote
You need to make sure your unicode literal strings have an N in front of them, otherwise the characters not included in the server's (or is it the OS's?) default character set will get down-converted (probably to question marks).


select top 1 tbLast from tblPeople
WHERE tbLast LIKE N'%Ñáðôïðïýëïõ%'


Gah! Two seconds!

Edited by - Arnold Fribble on 01/26/2004 12:15:27
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 01/26/2004 :  12:16:55  Show Profile  Visit nr's Homepage  Reply with Quote
lol.
I went back to edit in a comment about convertion straight after hitting submit and Arnold was already there.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Nick
Posting Yak Master

155 Posts

Posted - 01/26/2004 :  12:24:17  Show Profile  Visit Nick's Homepage  Reply with Quote
OK, that took care of that.

Now for the real problem (as that part of the problem was me just trying to debug the original problem)

I pass the field using a sproc. The sproc in turn uses dynamic sql to put together a rather complex query. If instead of exec'ing the dynamic sql I instead select it, my query ends up looking like the characters aren't in unicode.

Does this make any sense?
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 01/26/2004 :  12:34:48  Show Profile  Visit nr's Homepage  Reply with Quote
You have to use unicode everywhere.
The exec'd string, parameter received, parameter passed, all strings used to concatenate, ...

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000