Cyrillic Search

I changed one of the applications that I made for the Russian market. Everything was in order, there was a problem when entering data into the database, but it was solved by setting the page encoding to utf-8. Thus, insertion and extraction work fine. I ran into a problem, I just have no idea how to fight. When I executed the following query (simplified) in the mssql analysis of queries (so that it had no chance that it was corrupted in the code), I didn’t get the results, I even thought that there were a number of entries: (mysql version - 2005)

SELECT * FROM institutions WHERE city LIKE '%%' ORDER BY address1 

even if I change it:

 SELECT * FROM institutions WHERE city='' ORDER BY address1 

or some other option, it just doesn't work. The question is why?

PS If you do not see Cyrillic letters after I send this, he will look for Moscow as a city.

Does anyone have a solution or idea what to do?

+7
sql-server tsql sql-server-2005
source share
2 answers

OK just found the answer and it's lame :) a bit. You need to add N before the unicode string.

 SELECT * FROM institutions WHERE city LIKE N'%%' ORDER BY address1 

I will leave this in case someone gets stuck with him.

+21
source share

N tells SQL Server that it is unicode not ascii

+3
source share

All Articles