问题
There are already sever question and solution on accent insensitive search on stackoverflow, but none of them work for codepage 1250 (Central European and Eastern European languages).
How do I perform an accent insensitive compare (e with è, é, ê and ë) in SQL Server?
LINQ Where Ignore Accentuation and Case
Ignoring accents in SQL Server using LINQ to SQL
Modify search to make it Accent Insensitive in SQL Server
Questions about accent insensitivity in SQL Server (Latin1_General_CI_AS)
The problem is that accent insensitive collation are bidned to some specific codepages and that I am missing accent insensitive collation for 1250 codepage in MSDN documentation.
I need to modify the collation of the column to make Entity Framework working in accent insensitive way.
For example if I change a collation to SQL_LATIN1_GENERAL_CP1_CI_AI, c with accute is select as c without accute (U+0107) because wrong codepage.
How to solve this?
回答1:
SELECT *
FROM sys.fn_helpcollations()
WHERE COLLATIONPROPERTY(name, 'CodePage') = 1250
AND description LIKE '%accent-insensitive%';
Returns 264 results to choose from.
Picking the first one
SELECT N'è' COLLATE Albanian_CI_AI
UNION
SELECT N'é'
UNION
SELECT N'ê'
UNION
SELECT N'ë'
returns a single row as desired (showing all compared equal)
回答2:
OK, it seems that the link MSDN documentation is for SQL server 2008 I use SQL Server 2014, but I was not able to find any collation documentation for 2014.
But the solution is to list the collations from server for my code page:
SELECT name, COLLATIONPROPERTY(name, 'CodePage') AS CodePage
FROM fn_helpcollations()
where COLLATIONPROPERTY(name, 'CodePage') = 1250
ORDER BY name;
And I can see there is a undocumented collation Czech_100_CI_AI which works for me. Heureka!
来源:https://stackoverflow.com/questions/40460408/how-do-i-perform-an-accent-insensitive-compare-in-sql-server-for-1250-codepage