pzmrcd
Default port
Points: 1419
More actions
June 3, 2008 at 4:40 pm
#187344
Hi
I am trying to format a col (phone) in a table (prob thru a UDF).
from 1234567890 to 123-456-7890.
Any help
Thanks
Jeffrey Williams
SSC Guru
Points: 90303
June 3, 2008 at 5:05 pm
#823916
Here is one way (of many):
Declare @len int;
Declare @value varchar(10);
--Set @value = '4567890';
Set @value = '1234567890';
Set @len = len(@value);
Select @value, stuff(stuff(right('000' + @value, 10), 7, 0, '-'), 4, 0, '-');
Jeff
Jeffrey Williams“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers fasterManaging Transaction Logs
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply