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
我想在我的网站中使用unicode文本。我在数据库中有nvarchar(max)数据类型来存储数据。当我将unicode文本保存到数据库中时,它工作正常。但是当我尝试执行一些sql操作时,unicode文本被更改为“?????”例如,下面的查询
declare @unicodetext nvarchar(250)
set @unicodetext='बन्द'
select @unicodetext
results
What is the solution for this? Thanks
这是什么解决方案?谢谢
2 个解决方案
#1
11
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.
也许您注意到SQL Server在为您生成DDL脚本时使用N来表示任何引用的字符串输入。
#2
1
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:
那不行,但我在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().
4在SQL Server 2005中不推荐使用Hindi排序规则,因为在此SQL Server版本中使用了Windows 2000排序表。归类仍然存在于服务器中,但在将来的SQL Server版本中将不再受支持,并且它不会显示在:: 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().
5在SQL Server 2005中不推荐使用Hindi和Lithuanian_Classic归类。这些归类仍然存在于服务器中,但在将来的SQL Server版本中将不再支持它们,并且它们不会显示在:: fn_helpcollations()中。
for 2008:
Hindi (India) - Not available at server level
印地语(印度) - 不适用于服务器级别
#1
11
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.
也许您注意到SQL Server在为您生成DDL脚本时使用N来表示任何引用的字符串输入。
#2
1
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:
那不行,但我在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().
4在SQL Server 2005中不推荐使用Hindi排序规则,因为在此SQL Server版本中使用了Windows 2000排序表。归类仍然存在于服务器中,但在将来的SQL Server版本中将不再受支持,并且它不会显示在:: 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().
5在SQL Server 2005中不推荐使用Hindi和Lithuanian_Classic归类。这些归类仍然存在于服务器中,但在将来的SQL Server版本中将不再支持它们,并且它们不会显示在:: fn_helpcollations()中。
for 2008:
Hindi (India) - Not available at server level
印地语(印度) - 不适用于服务器级别