Skip to content
Advertisement

SQL: What are phone number formatting options?

SQL: What are phone number formatting options?

I query my SQL Database for a phone number:

816-123-4567

I want to output it is as:

816 123-4567.

What steps do I take to achieve this result in an SQL environment?

Advertisement

Answer

A standard SQL solution would be:

There may be simpler solutions in other databases. For instance, in SQL Server:

And in MySQL:

Note: These are specific the the format you have provided in your question. If you have other formats, then you might need more complicated logic.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement