tsql - problem with IN and LIKE in SQL when arguments contain special characters for a language -
I've got a key word table (MS SQL):
- Keygide qualifier primary that
- DA7E4E27-FDE5-4D43-A365-8A789164A816 tit kirkäna
- EED58875-FE41-4A18-A93C-A44AA62CEEEE htit kirkänbh
- A0EB795E-EE23-4990- BAB9 -897C93C70CE3 hit Kirknah
- F7F4632B-AC82-4DEB-B966-BBA8EF4D2C9E step Kerknab
- C0EB795E-EE23-4990-BAB9-897C93C70CE3 called Kirkns
- E2F4632B-AC82-4DEB-B966-BBA8EF4D2C9E nam kirkänbs
- A222795E-EE23-4990-BAB9-897C93C70CE3 tit kirkacb
- B333632B-AC82-4DEB-B966-BBA8EF4D2C9E Tit kirkaca
- 1222795E-EE23-4990-BAB9-897C93C70C81 htit kirkacbh
- E533632B-AC82-4DEB-B966- BBA8EF4D2C82 htit kirkacah
This simple query returns all the relevant records correctly:
Select * From the key word where 'kirkan%' like ' Code> - DA7 A4E27-FDI-4 4D 43-A365-8A 789164A 816 Title Ridness
- EED58875-FE41-4A18-A 9 3 C A44AA62 Siiiii HIT Kirkgb
- A0EB795E-EE23-4990-BAB9-897C93C70CE3 Hate Kirknah
- F7F4632B-AC82-4DEB-B966-BBA8EF4D2C9E step Krkanb
- C0EB795E- EE23-4990-BAB9-897C93C70CE3 nam kirkänas
- E2F4632B-AC82-4DEB-B966-BBA8EF4D2C9E nam kirkänbs
I specific match To limit resutls, use such a query qualifier: Choose from key word * where qualifier in ('tit', 'hat') and primitive 'kirak%' < / Code> which works perfectly:
- A222795E-EE23-4990-BAB9-897C93C70CE3 tit kirkacb
- B333632B-AC82- 4DEB-B966-BBA8EF4D2C9E tit kirkaca
- 1222795E-EE23- 4990-BAB9-897C93C70C81 htit kirkacbh
- E533632B-AC82-4DEB-B966-BBA8EF4D2C82 htit kirkacah
But when the phrase does not return it is a special character result:
And with that it is not that the 'qualifier in' ('tit', 'hat') qualifiers in the keyword like this:
select * from the keyword where (Qualifier = 'tita' or 'qualify' = 'htit') and 'kirkän%' like PrimitiveKey;
However it works like this:
- DA7E4E27-FDE5-4D43-A365-8A789164A816 tit kirkäna
- EED58875-FE41-4A18-A93C-A44AA62CEEEE htit kirk nbh
- A0EB795E-EE23-4990-BAB9 -897C93C70CE3 htit kirkänah
- F7F4632B-AC82-4DEB-B966-BBA8EF4D2C9E tit kirkänb
What What's wrong with the approach?
Maybe you need to use Unicode compatible datatypes. Try declaring PrimitiveKey column as nvarchar, try by putting the string you want to match with an 'N' like this: Selection * from the keyword (like the qualifier 'htit' like 'tit' or the qualifier) and like the PrimitiveKey% N'kirkän% '.
Comments
Post a Comment