Replace only match beginning of line
I am trying to write a function to replace Romanian diacritics (
) with their Latin letter equivalents (
The SQL Server
feature deals with
We seem to have a strange problem with
: they are only replaced if they are at the beginning of the line.
For example :
select replace(N'Ș', N'Ș', N'-') -- '-' # OK select replace(N'ȘA', N'Ș', N'-') -- '-A' # OK select replace(N'AȘ', N'Ș', N'-') -- 'AȘ' # WHAT?? select replace(N'ȘAȘ', N'Ș', N'-') -- '-AȘ' # WHAT??
I was able to reproduce this behavior on both SQL Sever 2008 R2 and SQL Server 2012.
Is there an explanation for these seemingly strange results? Or could it just be a mistake?
My default database collation is
source to share