Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need to seperate fname and lname Expand / Collapse
Author
Message
Posted Thursday, October 10, 2002 4:33 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, January 30, 2007 11:42 AM
Points: 74, Visits: 1
I have to seperate the fname and the lname into seperate columns. Example:
This is what the data currently looks like "John Doe" I need to make it look like "John","Doe". Any ideas

Thanks

Steve Johnson



Steve Johnson
Post #7377
Posted Thursday, October 10, 2002 4:52 PM
SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: Moderators
Last Login: Tuesday, August 26, 2014 8:57 AM
Points: 8,369, Visits: 736
As long as you are sure that it is only first and lastname in the data the use CHARINDEX to find ' '. Once you know the position of the ' ' you can manipulate any way you want.

"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)



Post #43603
Posted Thursday, October 10, 2002 5:34 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, June 6, 2014 2:06 PM
Points: 1,040, Visits: 277
Something like
select substring(name,1,charindex(' ',name)), substring(name,charindex(' ',name) + 1,len(name))

Gregory Larsen, DBA

If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples


Gregory A. Larsen, MVP

Need SQL Server Examples check out my website at http://www.sqlserverexamples.com
Post #43604
Posted Thursday, October 10, 2002 5:39 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, January 30, 2007 11:42 AM
Points: 74, Visits: 1
thanks guys, I got it to work...

Steve Johnson



Steve Johnson
Post #43605
Posted Friday, October 11, 2002 2:18 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Saturday, February 28, 2009 6:51 AM
Points: 1,489, Visits: 7
This article shows a couple of alternative ways to do it:

http://www.sql.nu/read.asp?id=7

--
Chris Hedgate @ Apptus Technologies (http://www.apptus.se)
http://www.sql.nu




--
Chris Hedgate http://www.hedgate.net/
Contributor to the Best of SQL Server Central volumes
Articles: http://www.sqlservercentral.com/columnists/chedgate/
Post #43606
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse