user1136875
user1136875

Reputation: 613

Hebrew and other languages in sql

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

Upvotes: 4

Views: 2340

Answers (2)

Kishore Kumar
Kishore Kumar

Reputation: 12864

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

Upvotes: 1

SQLMenace
SQLMenace

Reputation: 134923

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

Upvotes: 2

Related Questions