Navron
Navron

Reputation: 145

Format Phone Number SQL Server

I am working on a stored procedure that in part, pulls phone numbers from a database. In some cases, the number may be in an incorrect format. The correct format is: +714XXXXXXX, however there are cases where the number appears as, e.g: 142877261 or 7147267261. There are even some cases where the number appears as say, ++1749186372

How can i force the number to append +714 to the start while keeping the rest of the number intact?

Any help would be much appreciated.

Upvotes: 0

Views: 364

Answers (1)

Uma
Uma

Reputation: 32

You can take the 7 most right digits and unconditionnaly preprending +714

'+714' + right(phonenumber, 7)

Upvotes: 1

Related Questions