Hebrew and other languages in sql

不想你离开。 提交于 2019-12-23 14:39:19

问题


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?

Regards Yoav


回答1:


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

output

----
文

(1 row(s) affected)


----
?

(1 row(s) affected)

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?

In terms of searching, take a look at Performance Impacts of Unicode, Equals vs LIKE, and Partially Filled Fixed Width




回答2:


You have to use nchar instead of char and nvarchar instead of varchar during table creation.



来源:https://stackoverflow.com/questions/9760884/hebrew-and-other-languages-in-sql

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