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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, how could I separate the data f 2

Status
Not open for further replies.

nmc1975

MIS
Oct 23, 2001
15
0
0
US
Hi, how could I separate the data from this free field name field into three fields for first, middle, last names?

Example of data: DOE, JOHN JAMES

Need: Fname: JOHN, Mname: James, Lname: DOE
 
Maybe if you first put commas after each element of the name

DOE, JOHN, JAMES

your could create a comma delimited file and then you could pretty much do anything you wanted with it then.

Hope this helps...
 
Here is the SQL to parse your name field from table names:
SELECT names.name, Mid$([Name],1,Instr(1,[Name],",")-1) AS LName,
Mid$([Name],Instr(1,[Name],",")+2, IIF((Instr(Instr(1,[Name],",")+2, [Name]," ")-1)=-1, 99, ((Instr(Instr(1,[Name],",")+2, [Name]," ")-1) - Instr(1,[Name],",") )) ) AS FName,
Mid$([Name],IIF((Instr(Instr(1,[Name],",")+2, [Name]," ")-1)=-1, 99, Instr(Instr(1,[Name],",")+2 ,[Name]," ")+1 )) AS MName
FROM names;

Change the red names to whatever the name of the table is in your database.
Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top