Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Spliting Phone number with a space for Extension
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wsilage
Yak Posting Veteran

USA
82 Posts

Posted - 04/03/2013 :  09:16:35  Show Profile  Reply with Quote
I know this is probably something simple, but I tried googling it and didn't find anything. I have a field that has the phone and extension on in one.

How can I put a space after the phone number

This is what it looks like in my file....
215456700040081

I want it to look lik this...
2154567000 40081


This is what I tried to do...
left(c.CorrespondancePhone, 10)

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1054 Posts

Posted - 04/03/2013 :  09:27:12  Show Profile  Reply with Quote
if ext is always at the end and is of five digit then

declare @a varchar(20)
SET @a='215456700040081'
SELECT Replace(@a,Right(@a,5),'')+' '+Right(@a,5)

Cheers
MIK

Edited by - MIK_2008 on 04/03/2013 09:28:23
Go to Top of Page

wsilage
Yak Posting Veteran

USA
82 Posts

Posted - 04/03/2013 :  09:38:59  Show Profile  Reply with Quote
Thanks I will try that. I am not sure if the ext will only ever be 5 digits.
Go to Top of Page

russell
Pyro-ma-ni-yak

USA
5072 Posts

Posted - 04/03/2013 :  10:23:40  Show Profile  Visit russell's Homepage  Reply with Quote
declare @a varchar(20)
SET @a='2154567000400812'
SELECT LEFT(@a, 10) + ' ' + RIGHT(@a, len(@a)-10)
Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1054 Posts

Posted - 04/03/2013 :  10:44:33  Show Profile  Reply with Quote
so if the phone number is always at start and going to be of 10 digits, then use Russel's one :D

Cheers
MIK
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000