SQL-Server is ignoring my COLLATION when I'm using LIKE operator

前端 未结 2 1155
慢半拍i
慢半拍i 2021-01-14 01:17

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:

SE         


        
2条回答
  •  别那么骄傲
    2021-01-14 02:23

    You need to change the collation of the table COLUMN itself.

    select collation_name, *
    from sys.columns
    where object_id = object_id('tblname')
      and name = 'stringdata';
    

    If you're lucky it is as easy as (example)

    alter table tblname alter column stringdata varchar(20) collate Modern_Spanish_CI_AS
    

    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.

提交回复
热议问题