using unicode text in sql server 2008

牧云@^-^@ 提交于 2019-12-10 03:43:53

问题


I want to use unicode text in my site. I have nvarchar(max) data type in database to store the data. When I save unicode text into database, it works fine. However when i try to perform some sql operation the unicode text is changed to "?????" Eg, the query below

declare @unicodetext nvarchar(250)
set @unicodetext='बन्द'
select @unicodetext

results

What is the solution for this? Thanks


回答1:


Try

declare @unicodetext nvarchar(250)
set @unicodetext = N'बन्द'
select @unicodetext

Maybe you noticed that SQL Server uses N to any quoted string input when generating DDL scripts for you.




回答2:


you have to set your database collation to a collation that accepts this type of character or you can add the collation clause on your select like this (google told me this is a Hindi character)

declare @unicodetext nvarchar(250)
set @unicodetext='बन्द'
select @unicodetext
COLLATE Indic_General_90_CI_AS 

that wont work, but I found this on BOL for SQL Server 2005:

4 The Hindi collation is deprecated in SQL Server 2005 because the Windows 2000 sorting table is used in this SQL Server release. The collation still exists in the server, but it will not be supported in a future SQL Server release, and it does not show up in ::fn_helpcollations().

5 The Hindi and Lithuanian_Classic collations are deprecated in SQL Server 2005. These collations still exist in the server, but they will not be supported in a future SQL Server release, and they do not show up in ::fn_helpcollations().

for 2008:

Hindi (India) - Not available at server level



来源:https://stackoverflow.com/questions/10530290/using-unicode-text-in-sql-server-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!