Skip to content Skip to sidebar Skip to footer

Need Better Solution To Remove Special Characters And Numbers

Is there any better way to remove all the special characters and numbers in a column, not limited to one or two almost to remove all the special characters and numbers. As of now I

Solution 1:

You can simplify your function to one WHILE loop:

DECLARE@String NVARCHAR(MAX) ='231323Lig%$%$h$%t'DECLARE@Expression NVARCHAR(32) ='%[^A-Z]%'

WHILE PATINDEX(@Expression, @String) >0SET@String= STUFF(@String, PATINDEX(@Expression, @String), 1, '')

RETURN@String

A CLR function could be faster than the pure T-SQL implementation.

Regex.Replace(str, "[^a-zA-Z]+", "", RegexOptions.Compiled)

Post a Comment for "Need Better Solution To Remove Special Characters And Numbers"