SQLTeam.com | Weblogs | Forums

Remove leading zeros and non numeric characters

tsql

#1

Hi,

I have a string column of varying length. Some values may have leading zeros and /or non numeric characters. How can I remove leading zeros and characters from a string?

Thanks


#2
SELECT STUFF(YourStringColumn,1,PATINDEX('%[1-9]%',YourStringColumn)-1,'')
FROM YourTable;