telecommando
asked on
SQL Query to clean up phone numbers
I have a varchar(100) field in SQL Server 2008 with phone numbers. There is no set format, some are 1231234567, some are (123)123-4567, some are 123.123.4567, and various other iterations.
I need a query to just find the 10 numbers in the field (and ignore spaces and special charcters) and update them like this 123-123-4567.
I need a query to just find the 10 numbers in the field (and ignore spaces and special charcters) and update them like this 123-123-4567.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change this:
return @vchCleanedPhoneNumber
to
return left(@vchCleanedPhoneNumbe
This will only work if the number is always 10 digits.
Lee