3

I would like to replace Arabic character in select statement with another Arabic character in SQL server, example query:

select replace(ArabicName, 'أ', 'ا') as ArabicName from dataIndividual;

But it does not replace, the reason probably that SQL server does not read the character as Unicode but as ASCII (I guess).

Is there a way to pass a Unicode characters for replace function?

Note: I already tried collate after the Arabic character.

Mohammad Anini
  • 5,073
  • 4
  • 35
  • 46

1 Answers1

5

Prefix your string with N

select replace(ArabicName, N'أ' , N'ا') as ArabicName 
from dataIndividual;
M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • Ops! That is totally right! Don't know how I forgot that! Thanks a lot! – Mohammad Anini Aug 25 '15 at 17:05
  • I dont know why im getting " Incorrect syntax near 'N' " ERROR!! – Moslem Hadi Jul 13 '16 at 15:25
  • Thanks, in my case I need to cast to nvarchar(max) as shown below ,REPLACE(CAST( [ayahText] as nvarchar(max)),CAST( N'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ' as nvarchar(max)),'') as dd – user2662006 Apr 01 '20 at 19:38