Query Japanese Text in an NVarChar?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rowe_newsgroups

    Query Japanese Text in an NVarChar?

    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_ShortPhrase s
    WHERE Phrase = 'Home'
    //////////////

    But when I try with japanese, nothing is returned:

    /////////////
    SELECT *
    FROM tbl_ShortPhrase s
    WHERE Phrase = '再価格'
    /////////////

    I thought that the problem might be a conversion issue, so I tried the
    following with no success:

    /////////////
    SELECT *
    FROM tbl_ShortPhrase s
    WHERE Phrase = CONVERT(NVARCHA R, '再価格')
    /////////////

    Any help you can offer is appreciated!

    Thanks,

    Seth Rowe [MVP]
  • Tom van Stiphout

    #2
    Re: Query Japanese Text in an NVarChar?

    On Tue, 15 Apr 2008 13:06:19 -0700 (PDT), rowe_newsgroups
    <rowe_email@yah oo.comwrote:

    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_ShortPhrase s
    >WHERE Phrase = 'Home'
    >//////////////
    >
    >But when I try with japanese, nothing is returned:
    >
    >/////////////
    >SELECT *
    >FROM tbl_ShortPhrase s
    >WHERE Phrase = '???'
    >/////////////
    >
    >I thought that the problem might be a conversion issue, so I tried the
    >following with no success:
    >
    >/////////////
    >SELECT *
    >FROM tbl_ShortPhrase s
    >WHERE Phrase = CONVERT(NVARCHA R, '???')
    >/////////////
    >
    >Any help you can offer is appreciated!
    >
    >Thanks,
    >
    >Seth Rowe [MVP]

    Comment

    • rowe_newsgroups

      #3
      Re: Query Japanese Text in an NVarChar?

      On Apr 15, 11:36 pm, Tom van Stiphout <no.spam.tom7.. .@cox.netwrote:
      On Tue, 15 Apr 2008 13:06:19 -0700 (PDT), rowe_newsgroups
      >
      <rowe_em...@yah oo.comwrote:
      >
      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_ShortPhrase s
      WHERE Phrase = 'Home'
      //////////////
      >
      But when I try with japanese, nothing is returned:
      >
      /////////////
      SELECT *
      FROM tbl_ShortPhrase s
      WHERE Phrase = '???'
      /////////////
      >
      I thought that the problem might be a conversion issue, so I tried the
      following with no success:
      >
      /////////////
      SELECT *
      FROM tbl_ShortPhrase s
      WHERE Phrase = CONVERT(NVARCHA R, '???')
      /////////////
      >
      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]

      Comment

      Working...