Monday 18 June 2012

Function to replace all special characters

CREATE FUNCTION dbo.RemoveSpecialCharacter(@Str NVARCHAR(MAX)) RETURNS NVARCHAR(MAX)
AS
BEGIN
    SET @Str = Replace(@str, Char(13), ' ') --replace all enters with space
    SET @Str = Replace(@str, Char(9), ' ')--replace all tabs with space
    SET @Str = Replace(@str, Char(10), ' ')--replace all line feeds with space
    RETURN @Str
END

No comments:

Post a Comment