I have table in the database with a phone number column. The numbers look like this:
123456789
I want to format that to look like this:
Solutions that use SUBSTRING and concatenation + are nearly independent of RDBMS. Here is a short solution that is specific to SQL Server:
SUBSTRING
+
declare @x int = 123456789 select stuff(stuff(@x, 4, 0, '-'), 8, 0, '-')