Is there a function in SQL Server to normalize a unicode string? e.g.
UPDATE Orders SET Notes = NormalizeString(Notes, \'FormC\')
Unicode
try this CLR function
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString fnRemoveDiacritics(string text)
{
string stringFormD = text.Normalize(System.Text.NormalizationForm.FormD);
System.Text.StringBuilder retVal = new System.Text.StringBuilder();
for (int index = 0; index < stringFormD.Length; index++)
{
if (System.Globalization.CharUnicodeInfo.GetUnicodeCategory(stringFormD[index]) != System.Globalization.UnicodeCategory.NonSpacingMark)
retVal.Append(stringFormD[index]);
}
return retVal.ToString().Normalize(System.Text.NormalizationForm.FormC);
}
}
and in SQL
SELECT dbo.fnRemoveDiacritics('Äěščřžýáíé')
-- Returns: Aescrzyaie
thanks to http://www.dotnetportal.cz/blogy/4/Tomas-Jecha/663/NET-Tip-6-Ciste-odstraneni-diakritiky