Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2009
    Posts
    3

    Unanswered: find all values in unicode columns started with some unicode character

    I am working with arabic data and want to search in a table, all values started with a character in arabic. how would i do that???

    i am using C sharp with SQL server 2005. My inline query is look like as following

    "Select * from myTable Where aName Like '"+ myUnicodeVariable +"%'"

    does not return correct values.


    any suggestions????
    Last edited by wasan; 03-16-09 at 03:46.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by wasan
    "Select * from myTable Where aName Like '"+ myUnicodeVariable +"%'"

    does not return correct values.
    Ok - we know what it does not return, but what does it actually return? What is the value of myUnicodeVariable?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Mar 2009
    Posts
    3
    my dear myUnicodeVariable is C# sharp variable which contains a unicode char for instance 'م' an arabic character.

    so the final query that runs on SQL server would be

    "Select * from myTable Where aName Like 'م%'

    my question is whatever be the value of myUnicodeVariable... How i formulate a query so that i can get the values from database.

    is there some thing wrong in my query or there is something fishy with unicode / nvarchar

    where as

    select * from secondTable where bName Like 'M%'

    a same query give results on simple varchar fields...
    Last edited by wasan; 03-16-09 at 07:16.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    And what does it return dear?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You shouldn't be using concatenation - you should be using parameterised queries.

    Very simple example:
    Code:
    DECLARE @some_unicode_string nchar(1)
        SET @some_unicode_string = 'م'
    
    SELECT some_column
    FROM   some_table
    WHERE  CharIndex(@some_unicode_string, some_column) > 0
    George
    Home | Blog

  6. #6
    Join Date
    Mar 2009
    Posts
    3
    Quote Originally Posted by pootle flump
    And what does it return dear?
    it return nothing, ie no records found...

    Quote Originally Posted by gvee
    You shouldn't be using concatenation - you should be using parameterised queries.
    it seems logical gvee thanks for a good reply, but it still not works.... ie query return nothing although there are records which started with character 'م'.

Posting Permissions

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