希伯来语和其他SQL语言 [英] Hebrew and other languages in sql
问题描述
我在主机上有SQL Server,客户端是移动应用程序。
I have SQL Server on hosting, clients are mobile applications.
我有逻辑,即用户创建数据并将其存储在服务器上。一些数据是文本。但是用户可以输入英语,希伯来语或客户支持的任何其他语言。
I have logic that user creates data and store it on server. Some of the data is text. However user can enter english, hebrew or any other languages his client supports.
我需要在表格中指定哪种排序规则以支持所有语言?
Which Collation I need to specify to the tables to support all languages?
关于
Yoav
Regards Yoav
推荐答案
您需要将其存储为nvarchar并确保给文本加上N
you need to store it as nvarchar and make sure to prefix the text with N
example
declare @n nchar(1)
set @n = N'文'
select @n
GO
declare @n nchar(1)
set @n = '文'
select @n
输出
----
文
(1 row(s) affected)
----
?
(1 row(s) affected)
字符串前的N值告诉SQL Server将其视为unicode,请注意当您不使用N时会返回一个问号?
The N before the string value tells SQL Server to treat it as unicode, notice that you get a question mark back when you don't use N?
在搜索方面,请看一下 Unicode对性能的影响,Equals vs LIKE,和部分填充的固定宽度
In terms of searching, take a look at Performance Impacts of Unicode, Equals vs LIKE, and Partially Filled Fixed Width
这篇关于希伯来语和其他SQL语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!