Arif YILMAZ
Arif YILMAZ

Reputation: 5866

SQL Server turkish character situation

I am having a Turkish Character problem in ASP.NET and SQL Server. I have searchbox in asp.net and trying to do a search in database. However, I am having problems in Turkish characters. When I search for "GALVANİZ" which contains illegal "İ" character. the word "GALVANİZ" is in the database, I am sure.

When I do a simple select statement in SQL Server tool, it doesn't return anything either.

Here is the SQL

select * from Product where name like '%GALVANİZ%'

This doesn't return anything. How can I get it fixed?

thanks

Upvotes: 6

Views: 23917

Answers (4)

Volkan Barbaros Gurcan
Volkan Barbaros Gurcan

Reputation: 288

Yes, putting N in front of the search text will work. But in such a case you will have to use N constantly.

If you want it to find unicode characters in all cases (Turkish, Russian, Greek, Japanese, Arabic, etc.), your choice for DB Collation should be the UTF8 ones for the latin series. for example: Latin1_General_100_CI_AS_KS_SC_UTF8

This way you don't have to use the prefix N when searching.

Upvotes: 0

mert özakus
mert özakus

Reputation: 1

sudo systemctl stop mssql-server sudo /opt/mssql/bin/mssql-conf set-collation enter collation: Turkish_CI_AS sudo systemctl start mssql-server

Upvotes: 0

Arif YILMAZ
Arif YILMAZ

Reputation: 5866

I solved the question myself too. here is the solution

select * from product where name like N'%GALVANi%' collate Turkish_CI_AS

this is a much better solution

Upvotes: 7

Martin
Martin

Reputation: 16423

You can specify a collation in your query such as Turkish_CI_AI, or alternatively use the 'N' character with your strings to indicate that they are Unicode, as so:

select * from Product where name like N'%GALVANİZ%'

Upvotes: 20

Related Questions