×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Parsing a Name Field

Parsing a Name Field

Parsing a Name Field

(OP)
Greetings -

I am pulling data from our HR system and need to split the name into separate pieces.  Currently, the name field is in the following format: DOE,JOHN Q (there may or may not be a middle name/initial).  I can get the last name and the first name/MI but I can't split the first name and middle initial into separate data fields.  Here is my current code:

CODE

SELECT a.name AS NAME,
       a.number AS EENUM,
       b.status AS STATUS,
       b.dept AS DPTNO,
       c.name AS DPTNAME,
       b.jobcode AS JOBCODE,
       d.description AS JOBTITLE,
       LEFT(a.name, CHARINDEX(',', a.name)-1) AS LastName,
       SUBSTRING(a.name, CHARINDEX(',', a.name)+1,LEN(a.name)-CHARINDEX(',',a.name)) AS FirstName,
       
FROM LIVE_PPSHS..PPEmployeeFile a
LEFT JOIN LIVE_PPSHS..PPEmpPositionFields b ON a.employee=b.employee
LEFT JOIN LIVE_MIS..MisGlDept c ON b.dept=c.number
LEFT JOIN LIVE_PPSHS..PpJobCodeDictionary d ON b.jobcode=d.mnemonic
WHERE (b.status='ACTIVE' or b.status='LEAVE')

Thanks in advance for the assist.

RE: Parsing a Name Field

(OP)
My apologies..I posted this query to the wrong forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close