This is a discussion on Query Japanese Text in an NVarChar? within the SQL Server forums, part of the Microsoft SQL Server category; --> I apologize if this has been covered ad nauseum, but I didn't see it in my search. Basically, in ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I apologize if this has been covered ad nauseum, but I didn't 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'm 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 Tue, 15 Apr 2008 13:06:19 -0700 (PDT), rowe_newsgroups <rowe_email@yahoo.com> 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's too late. -Tom. >I apologize if this has been covered ad nauseum, but I didn't 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'm 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 Apr 15, 11:36 pm, Tom van Stiphout <no.spam.tom7...@cox.net> wrote: > On Tue, 15 Apr 2008 13:06:19 -0700 (PDT), rowe_newsgroups > > <rowe_em...@yahoo.com> 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's too late. > > -Tom. > > >I apologize if this has been covered ad nauseum, but I didn't 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'm 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] Ah, Thanks Tom, it's now working just as I hoped. Amazing how one character makes all the difference! Thanks, Seth Rowe [MVP] |
| Thread Tools | |
| Display Modes | |
|
|