Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1126

Re: Prefix literal unicode strings with NFor example in the AdventureWorks sample

From nilesh mantri <nmantri@aurustech.com>
Subject Re: Prefix literal unicode strings with NFor example in the AdventureWorks sample
Newsgroups comp.databases.ms-sqlserver
References <2ssa04l13cqet0nvinqp11dar5qpeftupv@4ax.com>
Message-ID <201261555249usenet@terrranews.com> (permalink)
Organization http://www.AltBinaries.com - Uncensored, Un-logged, Secure.
Date 2012-06-15 09:53 +0000

Show all headers | View raw


I have same problem for executing hibernate query. If I Prefix literal unicode strings with 'N' in HQL query, it will give exception as -->  org.hibernate.hql.ast.QuerySyntaxException: unexpected token: '?????????'

Any help will be Appreciates.

Thanks,
Nilesh

> On Tuesday, April 15, 2008 4:06 PM rowe_newsgroups wrote:

> I apologize if this has been covered ad nauseum, but I did not see it
> in my search.
> 
> Basically, in an nvarchar(150) column (called "Phrase" in the below
> samples) I store both english text as well as japanese (the table is
> for translations). What I am having trouble with is querying the table
> by the NVarChar field.
> 
> This works fine:
> 
> //////////////
> SELECT *
> FROM tbl_ShortPhrases
> WHERE Phrase = 'Home'
> //////////////
> 
> But when I try with japanese, nothing is returned:
> 
> /////////////
> SELECT *
> FROM tbl_ShortPhrases
> WHERE Phrase = '再価格'
> /////////////
> 
> I thought that the problem might be a conversion issue, so I tried the
> following with no success:
> 
> /////////////
> SELECT *
> FROM tbl_ShortPhrases
> WHERE Phrase = CONVERT(NVARCHAR, '再価格')
> /////////////
> 
> Any help you can offer is appreciated!
> 
> Thanks,
> 
> Seth Rowe [MVP]


>> On Tuesday, April 15, 2008 11:36 PM Tom van Stiphout wrote:

>> Prefix literal unicode strings with N
>> For example in the AdventureWorks sample db:
>> select * from Person.Contact
>> where FirstName = N'???'
>> 
>> (I had used Character Map to select some Japanese character and use it
>> for a FirstName)
>> 
>> Unsure why CAST or CONVERT does not work. I would have expected the
>> same. Most likely following the rules of precedence your unicode is
>> first converted to ansi, then CONVERTed to unicode but by that time
>> it is too late.
>> 
>> -Tom.


>>> On Wednesday, April 16, 2008 7:12 AM rowe_newsgroups wrote:

>>> Ah,
>>> 
>>> Thanks Tom, it is now working just as I hoped. Amazing how one
>>> character makes all the difference!
>>> 
>>> Thanks,
>>> 
>>> Seth Rowe [MVP]


Back to comp.databases.ms-sqlserver | Previous | Next | Find similar


Thread

Re: Prefix literal unicode strings with NFor example in the AdventureWorks sample nilesh mantri <nmantri@aurustech.com> - 2012-06-15 09:53 +0000

csiph-web