Solved

How to extract last and first name from a full name field

Posted on 2009-06-30
3
382 Views
Last Modified: 2012-05-07
I have a field calle fullname with the convention of  "Lastname, Firstname" in the varchar field.  Example   Jones, Bill.

How can I extract just the lastname and then just the firstname?

I want to end up with Bill Jones and I assume I must seperate them first, then concatonate to put them together in desired order.

Help please
0
Comment
Question by:SteveRed
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 24749965
SELECT LEFT (Name, CHARINDEX(',', Name)-1) FirstName, LTRIM( RIGHT (name, LEN(Name) - CHARINDEX(',', Name)) ) LasrtName
FROM urTabl
WHERE CHARINDEX(',', Name) > 0
0
 
LVL 3

Expert Comment

by:PurpleHaze
ID: 24751852
Another Way

Declare @FullName Varchar(100)
Set @FullName = 'Jones, Bill'
Select Substring(@FullName, CharIndex(',', @FullName, 0) + 2, DataLength(@FullName)) + ' ' + Substring(@FullName, 0, CharIndex(',', @FullName, 0)) As MyOrder
0
 

Author Closing Comment

by:SteveRed
ID: 31598554
thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now