I need to do the following modifications to a varchar(20) field:
- substitute accents with normal letters (like è to e)
- after (1) remove all the chars not in a..z
for example
'aèàç=.32s df'
must become
'aeacsdf'
are there special stored functions to achieve this easily?
UPDATE: please provide a T-SQL not CLR solution. This is the workaround I temporarly did because it temporarly suits my needs, anyway using a more elegant approach would be better.
CREATE FUNCTION sf_RemoveExtraChars (@NAME nvarchar(50))
RETURNS nvarchar(50)
AS
BEGIN
declare @TempString nvarchar(100)
set @TempString = @NAME
set @TempString = LOWER(@TempString)
set @TempString = replace(@TempString,' ', '')
set @TempString = replace(@TempString,'à', 'a')
set @TempString = replace(@TempString,'è', 'e')
set @TempString = replace(@TempString,'é', 'e')
set @TempString = replace(@TempString,'ì', 'i')
set @TempString = replace(@TempString,'ò', 'o')
set @TempString = replace(@TempString,'ù', 'u')
set @TempString = replace(@TempString,'ç', 'c')
set @TempString = replace(@TempString,'''', '')
set @TempString = replace(@TempString,'`', '')
set @TempString = replace(@TempString,'-', '')
return @TempString
END
GO