How do I skip dashes?
-
2 พฤษภาคม 2555 4:02
Hi,
I'm importing some data into our database. In the import data, phone numbers have the typical separators such as hyphens or parenthesis. In our database, we only keep numeric information for phone numbers. Is there a way for me to pick up only numbers without the hyphens, etc.? In other words, how can I form my select statement for phone number field so that I only get the numbers without any hyphens, etc.?
Thanks, Sam
ตอบทั้งหมด
-
2 พฤษภาคม 2555 4:10
Hi
You can use Replace.
Declare @Tbl Table(Phone Varchar(30)) Insert into @Tbl Values('234-334-444'),('(001)-344-343'),('343534343') Select Replace(Replace(REPLACE(Phone,'-',''),'(',''),')','') From @Tbl
Mark as Answer If Reply Was Helpful
Thanks
Kuldeep Bisht
Technical Lead @ Simplion Technologies
Blog : www.dbsimplified.com- ทำเครื่องหมายเป็นคำตอบโดย imsam67 2 พฤษภาคม 2555 4:12
-
2 พฤษภาคม 2555 4:12Makes perfect sense! Thank you!
Thanks, Sam