|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Format a string
I have a column in a database that is a phone number. The problem is that it is stored like so
4589958 Anyway that I can insert a "-" after the first 3 digits in SQL SELECT statement |
|
#2
|
||||
|
||||
|
SELECT (SUBSTRING(PHONE,0,3)+'-'+SUBSTRING(PHONE,4,7)) AS PHONENUM
FROM Table |
|
#3
|
|||
|
|||
|
Something like this should work as long as they are all in that format
Code:
to select -- SELECT Left(column1,3)+'-'+Right(column1,4) AS column1 FROM table1; to update-- update table1 set a = LEFT(column1,3) + '-' + right (column1,4) |
|
#4
|
|||
|
|||
|
Thanks for the response, I was trying SUBSTR instead of Substring!
Works Great! |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Format a string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|