Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting name into first and last 1

Status
Not open for further replies.

rjseals

Technical User
Nov 25, 2002
63
US
Hello,
This should be a pretty easy question but cant find the answer anywhere. I have a record of first and last names that I want to split into a first name and last name record. What would be the easiest query to use to split the two up?
Im not sure if it involves left(...) or what but any help would be appreciated.

Thanks
 
Assuming that the first and lastname is separated with a space.

Code:
select substring(c from 1 for position(' ' in c) - 1) as firstName,
substring(c from position(' ' in c) + 1) as firstName
from t

If you have more complicated names, including possible middle names etc., there is no general solution.

There is no function named left in ANSI SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top