Search code examples
sqlsql-serverarabic

How to concatenate Arabic string first and English second in SQL?


I am trying to concatenate Arabic string first and English second. But its printing English first and Arabic next.

Example

select  'يوم' + CONVERT(VARCHAR(10), @StartDate, 103)

it's printing in reverse


Solution

  • I don't have any knowloge about arabic but I think the following queries will help to solve your issue;

        select nchar(8237)  + (N'يوم') +  nchar(8236) +  CONVERT(VARCHAR(10), GETDAte(), 103) AS ConvertType
        UNION ALL
        select nchar(8237)  + reverse(N'يوم') +  nchar(8236) +  CONVERT(VARCHAR(10), GETDAte(), 103)
    
    
    +-----------------+
    |   ConvertType   |
    +-----------------+
    | ‭يوم‬10/11/2019 |
    | ‭موي‬10/11/2019 |
    +-----------------+
    

    Also you can refer the How to fix reversed arabic characters mixed with english in SQL server