Usage: Select dbo.StripSpecialChars(‘abc12+=\34def’); returns abc1234def
Create Function [dbo].[StripSpecialChars](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin
Declare @KeepValues as varchar(50)
Set @KeepValues = '%[^a-zA-Z0-9 ]%'
While PatIndex(@KeepValues, @Temp) > 0
Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')
Return @Temp
End
Adjust the @KeepValues as needed. Or if you want to get fancy, add it as a second input variable.