I'm working with Spanish database so when I'm looking for and "aeiou" I can also get "áéíóú" or "AEIOU" or "ÁÉÍÓÚ", in a where clause like this:
SELECT * FROM myTable WHERE stringData like '%perez%'
I'm expencting:
* perez
* PEREZ
* Pérez
* PÉREZ
So I changed my database to collation: Modern_Spanish_CI_AI
And I get only:
* perez
* PEREZ
But if I do:
SELECT * FROM myTable WHERE stringData like '%perez%' COLLATE Modern_Spanish_CI_AI
I get all results OK, so my question is, why if my database is COLLATE Modern_Spanish_CI_AI I have to set the same collation to my query???
I'm using SQL-Server 2008
You can use
COLLATE
, eg.both sides must have the same collation.
Others:
You need to change the collation of the table COLUMN itself.
If you're lucky it is as easy as (example)
But if you have constraints and/or schema bound references, it can get complicated.
It can be very difficult to work with a database with mixed collations, so you may want to re-collate all the table columns.