Search code examples
sql-serverdatabasereplacearabic

Replace arabic Letter in database


When changing the letter (ي) at the word to the letter (ى) changes and there is no problem, but the problem in changing the letter (ي) in the middles of the letter?

Is there a solution to ignore the middles of the letter?

DECLARE @FullName        VARCHAR(100)
SET @FullName = 'عبدالله عيد محمد علي'

Select @FullName, REPLACE(@FullName,'ى ','ي ')

-- عبدالله عيد محمد علي

-- عبدالله عىد محمد على


Solution

  • Try using their Unicode equivalents

    Select NCHAR(1740) as N'ي فارسي - Persian Ye', 
           NCHAR(1610) as N'ي عربي - Arabic Ye',
           NCHAR(1705) as N'ك فارسي - Persian Ke',
           NCHAR(1603) as N'ك عربي - Arabic Ke'
    

    Such as

    DECLARE @FullName  NVARCHAR(100)
    SET @FullName = N'عبدالله عيد محمد علي'
    Select @FullName, REPLACE(@FullName, NCHAR(1610), NCHAR(1740))
    

    With this output enter image description here