Menu Close

TSQL – Format Phone Numbers

This will teach you how to format a phone number from 1234567890 to (123) 456-7890.

SQL Server 2008:

SELECT [Phone] AS [Phone Number]
, ‘(‘+(SUBSTRING(Phone,1,3)+’) ‘+SUBSTRING(Phone,4,3) +’-‘ +SUBSTRING(Phone,7,4)) AS [Formatted Phone Number]
FROM (SELECT ‘1234567890’ AS [Phone]) as x

SQL Server 2012 and above:

SELECT
[Phone Numbers]
,FORMAT([Phone Numbers],'(###) ###-####’) AS [Formatted Phone Number]
FROM (SELECT ‘1234567890’ AS [Phone Numbers]) as x