Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove numeric characters...

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi guys!

I am assuming this is an easy one! Basically I am trying to strip any numeric character (ie 0 - 9) from a charater field. I am currently using this long-winded code:

Code:
SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE([MyField],'1',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','') AS MyField

..but is there a better/shorter way?

TIA
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 


replace myfield with chrtran(myfield,'123456789','')

 

Sorry missed out the 0


replace myfield with chrtran(myfield,'0123456789','')

 
lol :)

It is a conversion of a VFP process to a SQL stored procedure, so not too far off the mark!

I like work. It fascinates me. I can sit and look at it for hours...
 
thanks George :)

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top