Im unable to replace an special character. Could you please help me on this.
my input is:
MrsMontero
output should be:
Mrs Montero
Special character is not displaying correctly. please see the below image.
Create this function:
CREATE function RemoveSpecialCharacters(@Temp nvarchar(4000))
returns varchar(4000)
as
BEGIN
DECLARE @KeepValues as varchar(100)
-- you can add more characters like hyphen if you also want to keep those
SET @KeepValues = '%[^A-Z0-9 ]%'
WHILE PatIndex(@KeepValues, @Temp) > 0
SET @Temp = Stuff(@Temp, PatIndex(@KeepValues, 1, ' ')
RETURN @Temp
END
Now you can replace the characters.
SELECT dbo.RemoveSpecialCharacters('abc!"¤# ?123')
Result:
abc 123
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With