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
 General SQL Server Forums
 New to SQL Server Programming
 Fixing bad data in Phone Number

Author  Topic 

Niki
Yak Posting Veteran

51 Posts

Posted - 2012-10-23 : 11:49:30
Hi,
I have phone number like "4 15556666". How can I replace the spaces or bad data in phone in my SELECT statement.


Thank you,

Niki

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-10-23 : 12:00:18
SELECT REPLACE(PhoneNumber,' ','')
FROM yourTable
Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Niki
Yak Posting Veteran

51 Posts

Posted - 2012-10-23 : 12:12:17
Thank you jimf. I had REPLACE(phone,'', '0') in stead of REPLACE(Phone,' ','0')
Works like a charm :)

Niki
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-10-23 : 12:17:46
You are welcome. And welcome to SQL Team!

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -