Bakri Bitar
Bakri Bitar

Reputation: 1697

Convert Non-English text into English text using SQL

I have text normalizing method, I use it to convert non-English letters into English letters only.

I need to do the same functionality using SQL server


C# Method:

  private  string normalizeString(string inputWord)
        {
            StringBuilder stringBuilder = new StringBuilder();
            foreach (char c in inputWord.Trim().ToCharArray())
            {
                string normalizedChar = c.ToString()
                    .Normalize(NormalizationForm.FormD).Substring(0, 1);

                stringBuilder.Append(normalizedChar);
            }

            return stringBuilder.ToString();
        }

Example

Ä => A
ä => a
Ö => O
ö => o
Õ => O
õ => o
Ü => U
ü => u

Upvotes: 1

Views: 2583

Answers (2)

j.kahil
j.kahil

Reputation: 286

if you want to remove diacritics you can use Collate

for example:

select 'áéíóú' collate SQL_Latin1_General_Cp1251_CS_AS

this will return "aeiou"

Source

Upvotes: 3

gsharp
gsharp

Reputation: 27927

As per this Question there's no such native function in SQL Server. What you can do is to create a CLR Function for that.

Upvotes: 1

Related Questions