If you just select, do the following:
Select Replace(textct, Special_char, ' ') from mytable
If you are updating, do the following:
Update mytable Set textct = Replace(textct, Special_char, ' ')
Assuming these are nvarchars, do the following:
Select Replace(cast(textct as varchar),cast(Special_char as varchar), ' ') from mytable
If you want to remove all special characters, you will need to use this function:
Create Function RemoveSpecialCharacters (@text nvarchar(max)) Returns varchar(4000) AS BEGIN Declare @Return varchar(4000) = Cast(@text as varchar(4000)) While PatIndex('%[^az ]%', @Return) > 0 Set @Return = Stuff(@Return, PatIndex('%[^az ]%', @text), 1, ' ') Return @Return END Select RemoveSpecialCharacters(textct) from mytable
source share