SQL Server Performance

T-SQL unicode concatenation issues

Discussion in 'T-SQL Performance Tuning for Developers' started by aboovk, Apr 18, 2008.

  1. aboovk New Member

    While executing the below T-SQL code, it yields not results [the search word is a unicode text].
    After exploring i realized that the Unicode concatenation is not working well. All the characters converting to question marks.
    declare @search_word nvarchar(255)
    declare @sql nvarchar(255)
    set @search_word='اب';

    set @sql=N'select * from users where [fi_name] like ''%'+@search_word+'%''';
    print @sql
    exec sp_executesql @sql

    Any clues how to overcome this?
  2. Adriaan New Member

    The code works perfectly well, don't worry.
    The only problem is that the results are being shown in a font that does not support those characters. Just select a font that does.
  3. aboovk New Member

    Thanks for your reply.
    I was missing the charactor N before the uniocde string assignment which yielded results in ???.
    My assignement statement s changed as below to work this query in SQL Server Management Studio.
    set @search_word=N'اب';
  4. satya Moderator

    Using N is default for UNICODE characters for the correct results.

Share This Page