I usually use collate SQL_Latin1_General_CP1251_CI_AS
to remove accents (diacritics) like this.
select ('ěščřžýáíé' + '-' + (select 'ěščřžýáíé')) collate SQL_Latin1_General_CP1251_CI_AS
escrzyaie-escrzyaie
Unfortunately, after one of the search queries stopped working, I found out that collation is ignored when used in combination with for xml path
in subquery.
select ('ěščřžýáíé' + '-' + (select 'ěščřžýáíé' for xml path(''))) collate SQL_Latin1_General_CP1251_CI_AS
ěščřžýáíé-ěščřžýáíé
It is possible to work around this by using collation for each part separately, but I wonder why it doesn’t work in the previous example.
select ('ěščřžýáíé' collate SQL_Latin1_General_CP1251_CI_AS + '-' + (select 'ěščřžýáíé' collate SQL_Latin1_General_CP1251_CI_AS for xml path('')))
escrzyaie-escrzyaie
Advertisement
Answer
Cast it to varchar before concatenating
select ('ěščřžýáíé' + '-' + cast((select 'ěščřžýáíé' for xml path('')) as varchar(max))) collate SQL_Latin1_General_CP1251_CI_AS