M
M
mletov2018-06-14 12:53:35
SQL
mletov, 2018-06-14 12:53:35

Why doesn't LIKE work when searching in a database?

Please, prompt:
The program with basis on MSSQL has got in inheritance. But my predecessor messed up something with the encoding and it doesn’t work to select by field via LIKE or by hard comparison.
In MSSQLMS everything is displayed normally, not krakozyabry
The strangest thing is that sometimes there is a record that does not contain the desired expression.
COLLATION of the database: SQL_Latin1_General_CP1_CI_AS
Server COLLATION: Cyrillic_General_CI_AS (I suspect, just because of the mismatch with the collation of the database)
COLLATION for the field by which I choose: database default
Tried

SELECT *
FROM table
WHERE  comment LIKE '%к%'

SELECT *
FROM table
WHERE  comment LIKE '%к%' COLLATE SQL_Latin1_General_CP1_CI_AS

SELECT *
FROM table
WHERE  comment LIKE '%к%' COLLATE Cyrillic_General_CI_AS

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Skorzhinsky, 2018-06-16
@AndyKorg

You can read about Collate here .
Assuming that your letter "k" is Russian and there are rows with such a letter in the table, it remains only to sin on setting the client's code page.

V
ViaCom, 2018-06-22
@ViaCom

SELECT *
FROM table
WHERE  comment COLLATE Cyrillic_General_CI_AS
 LIKE '%к%' COLLATE Cyrillic_General_CI_AS

bring all fields to one collate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question