Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
reynet
Starting Member
4 Posts |
Posted - 2007-04-27 : 14:02:23
|
| I have a text field that stores phone numbers in the following format5555555555I need change the existing text to this format(555)555-5555I basically want to change the filed data if the length is 10 characters that way I will only change data that is in the wrong format. Anyway to do this easily with a simply update query? Any help would be most appreciated. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-04-27 : 14:16:38
|
| This is a display issue. You should be storing the data as 10 digits, then your application should format it when viewing the data.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
reynet
Starting Member
4 Posts |
Posted - 2007-04-27 : 14:20:05
|
| That's the problem the application stores it in the phone format and is expecting it this way. The user imported all the numbers from a spread sheet that had the straight number format and the application screws up the number when displayed. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-04-27 : 14:24:44
|
| Check this out:DECLARE @s char(10)SET @s = '1234567890'SELECT '(' + SUBSTRING(@s, 1, 3) + ')' + SUBSTRING(@s, 4, 3) + '-' + SUBSTRING(@s, 7, 4)You can use it in an update statement. Just substitute your column for my variable. Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
reynet
Starting Member
4 Posts |
Posted - 2007-04-27 : 14:38:44
|
| Thanks Worked great! |
 |
|
|
|
|
|