How can I remove accents on a string?

前端 未结 5 1925
悲&欢浪女
悲&欢浪女 2020-12-08 00:10

I have the following string

áéíóú

which I need to convert it to

aeiou

How can I achieve it? (I don\'t nee

5条回答
  •  误落风尘
    2020-12-08 00:39

    I had the same problem. In Greek for proper conversion to UPPER() you must suppress accent. Changing collation caused issues in other applications. Putting some REPLACE() functions I had more control on the behavior maintaining collation. Below is my ToUpperCaseGR function.

        SET ANSI_NULLS ON
        GO
        SET QUOTED_IDENTIFIER ON
        GO
    
        create FUNCTION ToUpperCaseGR
        (
         @word nvarchar(max)
        )
        RETURNS nvarchar(max)
        AS
        BEGIN
            -- Declare the return variable here
            declare @res nvarchar(max)
            set @res = UPPER(@word)
            set @res = replace(@res,'Ά','Α')
            set @res = replace(@res,'Έ','Ε')
            set @res = replace(@res,'Ί','Ι')
            set @res = replace(@res,'Ή','Η')
            set @res = replace(@res,'Ό','Ο')
            set @res = replace(@res,'Ύ','Υ')
            set @res = replace(@res,'Ώ','Ω')
    
    
            -- Return the result of the function
            RETURN @res
    
        END
        GO
    

提交回复
热议问题