Script to Strip Non Numeric Characters from string

Posted on : 24-04-2012 | By : Devi Prasad | In : SQLServerPedia Syndication, T-SQL Code Examples


Below sample script strips (removes) non numeric Characters from string (varchar)


SET @VARCHARString = ‘000012W`”ASDASDS3A@!#@!#_)+)_4)’


–Remove non numeric charecters from the varchar variable
WHILE PATINDEX(‘%[^0-9]%’, @VARCHARString) > 0
SET @VARCHARString = STUFF(@VARCHARString, PATINDEX(‘%[^0-9]%’, @VARCHARString), 1, ”)


Reference : Devi Prasad (

Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.

Your Ad Here

Tags: ,