locked
Problem with some Arabic special characters in my query. RRS feed

  • Question

  • Hi

    i have a simple query which filter data with like operator. here is my sample query :

    select * from Aparteman where address like '%هو%'

    As u can see, this simple query execute currectly, and returns a result, but when i add an Arabic special character 'ی' it does not return result! here is my query :

    select * from Aparteman where address like '%هوی%'

    my data in database have this character but not show in search result when i use this sepcial character! even, if i copy/paste that word from my database into my query, i'm facing the same problem!

    The 'Address' column is nvarchar(max).

    Where is the problem and how to solve it?

    thanks in advance.


    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

    Monday, January 8, 2018 12:01 PM

Answers

  • Can you try it with the N prefix (signifying that the search string is Unicode)?

    select * from Aparteman where address like N'%هوی%'

    Thanks,
    Sam Lester (MSFT)


    https://blogs.msdn.microsoft.com/samlester/

    Twitter - @SQLSamLester

    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

    • Proposed as answer by Xi Jin Tuesday, January 9, 2018 2:24 AM
    • Marked as answer by Hamed_1983 Tuesday, January 9, 2018 10:22 AM
    Monday, January 8, 2018 12:11 PM
  • Hi

    i have a simple query which filter data with like operator. here is my sample query :

    select * from Aparteman where address like '%هو%'

    As u can see, this simple query execute currectly, and returns a result, but when i add an Arabic special character 'ی' it does not return result! here is my query :

    select * from Aparteman where address like '%هوی%'

    my data in database have this character but not show in search result when i use this sepcial character! even, if i copy/paste that word from my database into my query, i'm facing the same problem!

    The 'Address' column is nvarchar(max).

    Where is the problem and how to solve it?

    thanks in advance.


    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

    As its unicode you've enclose it with N

    ie. like

    select * from Aparteman where address like N'%هوی%'

    Also any variables, parameters etc which handles these values have to be of unicode type (nchar,nvarchar etc)


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Xi Jin Tuesday, January 9, 2018 2:24 AM
    • Marked as answer by Hamed_1983 Tuesday, January 9, 2018 10:22 AM
    Monday, January 8, 2018 12:18 PM

All replies

  • Can you try it with the N prefix (signifying that the search string is Unicode)?

    select * from Aparteman where address like N'%هوی%'

    Thanks,
    Sam Lester (MSFT)


    https://blogs.msdn.microsoft.com/samlester/

    Twitter - @SQLSamLester

    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

    • Proposed as answer by Xi Jin Tuesday, January 9, 2018 2:24 AM
    • Marked as answer by Hamed_1983 Tuesday, January 9, 2018 10:22 AM
    Monday, January 8, 2018 12:11 PM
  • Hi

    i have a simple query which filter data with like operator. here is my sample query :

    select * from Aparteman where address like '%هو%'

    As u can see, this simple query execute currectly, and returns a result, but when i add an Arabic special character 'ی' it does not return result! here is my query :

    select * from Aparteman where address like '%هوی%'

    my data in database have this character but not show in search result when i use this sepcial character! even, if i copy/paste that word from my database into my query, i'm facing the same problem!

    The 'Address' column is nvarchar(max).

    Where is the problem and how to solve it?

    thanks in advance.


    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

    As its unicode you've enclose it with N

    ie. like

    select * from Aparteman where address like N'%هوی%'

    Also any variables, parameters etc which handles these values have to be of unicode type (nchar,nvarchar etc)


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Xi Jin Tuesday, January 9, 2018 2:24 AM
    • Marked as answer by Hamed_1983 Tuesday, January 9, 2018 10:22 AM
    Monday, January 8, 2018 12:18 PM