Normalize unicode string in SQL Server?

前端 未结 4 1781
心在旅途
心在旅途 2021-01-05 02:48

Is there a function in SQL Server to normalize a unicode string? e.g.

UPDATE Orders SET Notes = NormalizeString(Notes, \'FormC\')

Unicode

4条回答
  •  伪装坚强ぢ
    2021-01-05 03:02

    In the absence of an in-built solution in SQL Server and if you don't want to write a C# function, you could use the translate function to do that manually as such:

    select translate(last_name, 'éêëèàäçïîìôöòûù', 'eeeeaaciiiooouu') from employees

    You can also use the following solution from: https://coderwall.com/p/a6koxq/how-to-remove-diacritics-in-sql-server

    The easiest way to remove diacritics from a string in SQL Server is to collate the string using a character set that does not include diacritics, such as :

    SELECT 'àéêöhello!' Collate SQL_Latin1_General_CP1253_CI_AI

    This will output:

    aeeohello!

    This work only if you are not using a unicode string, so cast it as varchar first if you have a unicode string.

提交回复
热议问题