Right to left in SQL Server

Consider the following query containing both Persian (right to left language) and English (language from left to right):

SELECT 'نرم افزار SQL سرور' 

the required result is a string:

سرور SQL نرم افزار

Is there any function or any other way to convert a string from ltr to rtl ??

+7
sql sql-server-2008-r2
source share
1 answer

Add N to the string literal: SELECT N'نرم افزار SQL سرور' . This is necessary for the correct interpretation of Unicode characters. ( Source )

Important. In some cases, please avoid using the standard copy-paste to put SELECT in the SSMS command window. This may affect the RTL / LTR order . Instead, try opening a properly composed file using File> Open .

And regarding your comment :

the result should be: سرور SQL نرم افزار`

I admit that I understand the RTL spelling system only partially, but from what I see, Persian words are output exactly as you typed them (even when reading from right to left). Could you show me, based on the Unicode Bi-Directional Algorithm or similar standards document, why should the word order be replaced by SQL Server? Should there be any changes you expect from preprocessing elsewhere by sending the expected SELECT N'سرور SQL نرم افزار' ? I see no reason why SQL SELECT should make this change. If this happened, what would happen if you feed the result of such a SELECT to another SELECT ? Another transformation? I have reason to believe that the SQL server correctly interprets your input.

Hint: maybe you can try to surround the RTL text with various directional formatting characters .

Try using the same SELECT with a MySQL server on SQL Fiddle . Different servers and technologies, but the same result as Microsoft SQL Server.

Result of SSMS with MS SQL Server: enter image description here

Conclusion: to get the expected result, please make an appropriate contribution.

Related: Conversion of the expected word order can be performed using the appropriate settings in the user interface.

+4
source share

All Articles