Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Removing all char other than digits in string

Author  Topic 

ssnaik84
Starting Member

15 Posts

Posted - 2008-07-08 : 01:20:51
hi..
I want to build a function which can remove all characters other than digits [0-9] in a string.
e.g.
phone
(020) 333-333-4444 or 020-333-333-4444 or 020 (3)33 44444
whatever would be the combination..
Result should be: 0203333334444

Can I use regular expression with string functions?
since, i have to run it on a particular column of a table.

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-08 : 01:37:39
see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79083&SearchTerms=fnFilterString


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-07-08 : 02:55:43

Hi friend ..
Just check this

select replace(replace(replace(replace('(020) 333-333-4444 ','-',''),'(',''),')',''),' ','')
Go to Top of Page
   

- Advertisement -