Sample SQL Script :


ALTER Function [dbo].[RemoveNonAlphaNumericCharacters](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin

 Declare @KeepValues as varchar(50)
 Set @KeepValues = '%[^(a-z0-9-)]%'
 While PatIndex(@KeepValues, @Temp) > 0
 Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '-')

 Return @Temp
End

GO
Select dbo.[RemoveNonAlphaNumericCharacters]('abc***1234 5678ghi90jkl@##$%%AAAA^^^^AAAAAAAAA 1111')