Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persian numbers in SQL Server 2005

I'm trying to add some persian text to my SQL Server 2005 database.

There is no problem with letters, but persian numbers (۱،۲،۳،...) are converted to ?...

For example, if I add this text (سلام ۱۲۳۴‍‍‍) to database, there will be (سلام ؟؟؟؟) in database/

What should I do? (for example, which collation should I use?)

I'm using Arabic_CI_AS collation. in this list, Farsi (Persian) collation is Arabic_CI_AS (SQL Server 2005 doesn't have Persian collation, but 2008 has!)

Note: I can't use newer versions of SQL Server...

like image 411
Mahdi Ghiasi Avatar asked Jun 26 '12 10:06

Mahdi Ghiasi


2 Answers

If you insert string literals, be sure to mark Unicode strings with N'', such as

select N'سلام ۱۲۳۴‍‍‍'

Next, make sure whether the question marks are only a display problem in SSMS:

declare @t nvarchar(50) = N'سلام ۱۲۳۴‍‍‍'
select unicode(substring( @t, 1, 1))
select unicode(substring( @t, 2, 2))
select unicode(substring( @t, 3, 3))
select unicode(substring( @t, 4, 4))

returns the Unicode values for each character:

1587
1604
1575
1605

I remember that SSMS 2005 had problems displaying certain Unicode ranges in the results window.

like image 112
devio Avatar answered Nov 03 '22 06:11

devio


You Can Use Arabic_CI_AI collation and Solve this problem I hope that help you..

like image 28
Mustafa Salman Avatar answered Nov 03 '22 06:11

Mustafa Salman