Function for Removing String Characters in Sql

Function for Removing String Characters in Sql

CREATE FUNCTION RemoveStringCharacters
(
@string nvarchar(max),
@remove nvarchar(100)
)
RETURNS nvarchar(max)
AS
BEGIN
WHILE @string LIKE ‘%[‘ + @remove + ‘]%’
BEGIN
SET @string = REPLACE(@string,SUBSTRING(@string,PATINDEX(‘%[‘ + @remove + ‘]%’,@string),1),”)
END
RETURN @string
END

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply