Results 1 to 8 of 8

Thread: unicode

  1. #1
    Join Date
    Jul 2004
    Posts
    34

    Unanswered: unicode

    Hi everybody
    My database contain both chinese and english datas. When working with select command i am able to retrieve only english datas eventhough i have made all the datatypes nvarchar.
    I am using a stored procedure to retrieve the data

    declare @chinese nvarchar
    select field_name from Table_name
    where name like @chinese+'%'

    The qurey is working if we give
    select * from table name where name like N'政府机关'

    pls help me to put this query in a procedure

    pls reply
    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If you think about the way that the percent sign (%) matches, you have two very different queries. The second query isn't using any wildcard at all, it could use = as well as it uses LIKE. The first query is using a wildcard after the constant, so it will find any string that STARTS with the characters you provide.

    -PatP

  3. #3
    Join Date
    Jul 2004
    Posts
    34

    unicode

    ya i understood what u said but thats not the case . Even if i remove the % sign also i wont get the result.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Interesting! If you check the BOL comments about LIKE matching, there are some differences between the way that LIKE is processed for ASCII data and Unicode data, especially regarding trailing blanks. Could this be your problem?

    -PatP

  5. #5
    Join Date
    Jul 2004
    Posts
    34

    unicode

    declare @x nvarchar(100)
    select @x ='政府机关'
    select @x
    IT display like ?????
    i need like '政府机关'
    i have one query for checking chinese company name as unicode

    suppose i given like N''政府机关' It is working fine . but i pass

    '政府机关' directly from front end . I can't get any result .


    I have no idea how to solve these unicode problem

  6. #6
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    What tool (Query Analyzer, OSQL, Visual Studio, etc) are you using to submit these queries? It looks to me like it is not passing Unicode either to, from, or both ways to the server. I suspect that there is one piece somewhere in the data transfer that is using UTF-8 encoding or something like it, that breaks the Unicode datapath.

    -PatP

  7. #7
    Join Date
    Jul 2004
    Posts
    34

    unicode

    we r using c# .net as front end .
    The chinese datas that are present in the database in not entered through the key board. Just cut and paste. So it wont be considered as characters. It will be considered as ascii code. Then i think it will come like this ????. OH no idea..
    Thank u very much

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Try to put the query of interest into either Query Analyzer, or if you don't have Query Analyzer then use OSQL.EXE from a command prompt. See if the query works correctly in that environment (I strongly suspect that it will).

    If the query works Ok there, then the problem is almost certainly that something in the C# code is treating the data as 8 bit characters instead of Unicode. It only takes ONE place that treats the string as 8 bit anywhere in the datapath to reduce the entire datapath to handling only 8 bit data!

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •