Last active
February 21, 2019 22:02
-
-
Save hornofj/9be3b62966fdba861ee65bf6aea56e15 to your computer and use it in GitHub Desktop.
Remove accents SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop function if exists fn_remove_accents; | |
delimiter | | |
create function fn_remove_accents( textvalue varchar(20000) ) | |
returns varchar(20000) | |
begin | |
set @textvalue = textvalue; | |
-- ACCENTS | |
set @withaccents = 'ĎŇňŘřČ莞ĽľĚ슚ŽžÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØßÙÚÛÜŮÝŸÞàáâãäåæçèéêëìíîïñòóôõöøùúûüůýÿþƒ'; | |
set @withoutaccents = 'DdTtNnRrCcZzLlEeSsZzAAAAAAACEEEEIIIINOOOOOOsUUUUUYYBaaaaaaaceeeeiiiinoooooouuuuuyybf'; | |
set @count = length(@withaccents); | |
while @count > 0 do | |
set @textvalue = replace(@textvalue, substring(@withaccents, @count, 1), substring(@withoutaccents, @count, 1)); | |
set @count = @count - 1; | |
end while; | |
-- SPECIAL CHARS | |
set @special = '!@#$%¨&*()_+=§¹²³£¢¬"`´{[^~}]<,>.:;?/°ºª+*|\\'''; | |
set @count = length(@special); | |
while @count > 0 do | |
set @textvalue = replace(@textvalue, substring(@special, @count, 1), ''); | |
set @count = @count - 1; | |
end while; | |
return @textvalue; | |
end | |
| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment