How to remove accent and special characters from a string in SQL Server

Views: 38.619
Reading Time: 2 minutes

Hello guys,
Good day.

In this post I will briefly comment on a User Defined Function (UDF) that I used to remove accents and special characters from a string in SQL Server.

Removing Accents

There are several ways to do this, such as using a UDF to do this work, a SQLCLR function, or the one I prefer, which is using COLLATION.

Using a UDF Function

SQL Server - Remove 2 Accentuation

Using a SQLCLR Function

SQL Server - Remove Accentuation - SQL CLR

Using Collation
In my opinion, this is the best way to remove accent from a string in SQL Server. It is the fastest way to do it and is native to the database itself (ie universal, works on any SQL Server database).

SQL Server - Remove Accentuation - Collate

To know all types of COLLATION, you can run the command below:

Removing Special Characters

Using the function below, you can remove those special characters from a string and return only the alphanumeric characters.

SQL Server - Remove Special Characters - UDF

That's it folks!
To the next.