Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REPLACE and Unicode characters in SQL

I have some data with messed-up accented characters. For example in the data we have things like

ClΘmentine

that should should read

Clémentine

I'd like to clean it up with a script, but when I do this for example

  Select Replace('ClΘmentine', 'Θ', 'é')

this is what I get:

Clémenéine

Apparently Θ matches both Θ and t. Any ideas what's going on and what I can do to make this work?

like image 203
Herb Caudill Avatar asked Oct 16 '08 18:10

Herb Caudill


1 Answers

Try this (assuming you have SQL server, where I could just reproduce that behavior):

Select Replace(N'ClΘmentine', N'Θ', N'é')

You must tell SQL Server that it deals with Unicode strings, that is what the N is for.

like image 125
Tomalak Avatar answered Sep 28 '22 09:09

Tomalak