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

Parse Excel data 1

Status
Not open for further replies.

krets

Technical User
Dec 29, 2006
214
US
How would I go about writing a query that would parse a Name field in Excel formatted as:

Lastname, Firstname

And return the data so it was separated into two columns called LastName and FirstName?
 
A starting point (SQL code):
SELECT xlCol, Left(xlCol,InStr(xlCol,',')-1) AS Lastname, Trim(Mid(xlCol,InStrRev(xlCol,',')+1)) AS Firstname
FROM yourTable
WHERE xlCol Like '*,*'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top