Wednesday, April 30, 2008

Case insensitive search in mssql

Recently I needed to make a case insensitive search on a table in Microsoft SQL Server.

Because I wanted to overcome common incorrect type errors on the names of people, I needed that this particular search be accent insensitive.

After implementing another alternative I found I could do it in a better way:

select * from names

WHERE (name COLLATE Latin1_General_CI_AI) LIKE '%antonio%'

The list of collations can be obtained by consulting:

SELECT * FROM fn_helpcollations()

No comments: