Quantcast
Channel: Für Entwickler: SQL Server Forum
Viewing all articles
Browse latest Browse all 1772

Umlaufehler schnell korrigieren

$
0
0

Hallo,

in unserer SQL-Server-Datenbank laufen Daten aus verschiedenen Systemen zusammen.

Leider haben wir immer wieder das Problem, das Umlaute in Straßennamen und Ortsbezeichnungen verhunzt dargestellt werden.

Um Abhilfe zu schaffen hatte ich mal eine Funktion gebaut mit der die diversen Fehler, die ich im Laufe der zeit gefunden habe größtenteils repariert werden. Als Problem stellt sich aber mittlerweile heraus, dass das ganze nicht besonders performant ist.

USE [master]
GO
/****** Object:  UserDefinedFunction [dbo].[udf_replace_n]    Script Date: 07/09/2013 13:58:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[udf_replace_n] (@str NVARCHAR(max))

RETURNS VARCHAR(max) AS

BEGIN
	SET @str = REPLACE (@str, N'ä', N'ä')
	SET @str = REPLACE (@str, N'{', N'ä')
	SET @str = REPLACE (@str, N'Ä', N'A')
	SET @str = REPLACE (@str, N'ü', N'ü')
	SET @str = REPLACE (@str, N'#', N'ü')
	SET @str = REPLACE (@str, N'++', N'ü')
	SET @str = REPLACE (@str, N'}', N'ü')
	SET @str = REPLACE (@str, N'Ü', N'Ü')
	SET @str = REPLACE (@str, N'ö', N'ö')
	SET @str = REPLACE (@str, N'÷', N'ö')
	SET @str = REPLACE (@str, N'', N'ö')
	SET @str = REPLACE (@str, N'+Â', N'ö')
	SET @str = REPLACE (@str, N'Ö', N'Ö')
	SET @str = REPLACE (@str, N'|', N'ö')
	SET @str = REPLACE (@str, N'ß', N'ß')
	SET @str = REPLACE (@str, N'+ƒ', N'ß')
	SET @str = REPLACE (@str, N'~', N'ß')
	SET @str = REPLACE (@str, N'á', N'ß')
	SET @str = REPLACE (@str, N'á', N'ß')
	SET @str = REPLACE (@str, N'´', N'''')
	SET @str = REPLACE (@str, N'traáe', N'traße')
	SET @str = REPLACE (@str, N'"', N'')
	SET @str = REPLACE (@str, N'û', N'-')
	SET @str = REPLACE (@str, N'¯', N'ß')
	RETURN @str
END

Hat jemand eine Idee, wie das besser gelöst werden kann?

Gruß

cheapy


Viewing all articles
Browse latest Browse all 1772


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>