Persian numbers in SQL Server 2005

2019-05-01 22:26发布

问题:

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...

回答1:

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.



回答2:

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