September 18, 2008 at 1:28 pm
Hi, I am looking for a SQL function which converts (not remove) a string containing accented characters into the same string without the accented characters.
For example: select myfunction('hóla') should return hola
Any help would be much appreciated.
September 18, 2008 at 6:58 pm
Hi there,
Try this one
SELECT REPLACE('hóla','ó','o')
Tell me if this was helpful or if it needs some modifications.. Thank you ^__^
_____________________________________________
[font="Comic Sans MS"]Quatrei Quorizawa[/font]
:):D:P;):w00t::cool::hehe:
MABUHAY PHILIPPINES!
September 18, 2008 at 7:14 pm
Thanks. I used your function and added a few more concatenated replace sentences to deal with the possible accented characters in any string.
Thanks again
September 18, 2008 at 7:25 pm
You welcome ^__^
_____________________________________________
[font="Comic Sans MS"]Quatrei Quorizawa[/font]
:):D:P;):w00t::cool::hehe:
MABUHAY PHILIPPINES!
September 6, 2010 at 7:18 am
I have written my own fucntion.
You can test it with:
SELECT dbo.Format_RemoveAccents( 'ñaàeéêèioô; Œuf un œuf' )
You will optain ==> naaeeeeioo; OEuf un oeuf
The function:
CREATE FUNCTION dbo.Format_RemoveAccents( @STR varchar(8000) )
RETURNS varchar(8000)
AS
BEGIN
/*
EXEMPLE :
SELECT dbo.Format_RemoveAccents( 'ñaàeéêèioô; Œuf un œuf' )
==> naaeeeeioo; OEuf un oeuf
By Domilo
*/
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'a', 'a' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'e', 'e' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'i', 'i' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'o', 'o' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'u', 'u' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'y', 'y' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'n', 'n' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'œ', 'oe' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'æ', 'ae' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'ß', 'ss' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 's', 's' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'A', 'A' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'E', 'E' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'I', 'I' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'O', 'O' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'U', 'U' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'Y', 'Y' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'N', 'N' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'Œ', 'OE' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'Æ', 'AE' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'ß', 'SS' )
SET @STR = Replace( @STR COLLATE Latin1_General_CS_AI, 'S', 'S' )
RETURN @STR
END
February 24, 2011 at 10:00 am
February 27, 2011 at 2:37 am
xavier.villafuerte (9/18/2008)
Hi, I am looking for a SQL function which converts (not remove) a string containing accented characters into the same string without the accented characters.
I just want to check that you want to remove accents permanently? If you are just doing it to make string comparisons work as you would like, you could just use an explicitly accent-insensitive collation:
DECLARE @String CHAR(22) = N'ñaàeéêèioô; Œuf un œuf'
;
IF @String COLLATE LATIN1_GENERAL_CS_AS = N'naaeeeeioo; Œuf un œuf'
PRINT 'Match 1'
;
IF @String COLLATE LATIN1_GENERAL_CS_AI = N'naaeeeeioo; Œuf un œuf'
PRINT 'Match 2'
;
^^^ Prints 'Match 2' only ^^^
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply