I am using Oracle SQL. I needed to split a full name field into separate columns for the last, first and middle initial.
The name field is always formatted with last name, first name middle (last comma first space middle)
I've got the last and first name columns but having trouble getting the middle initial column displaying the correct letter. The middle name field can be entered as the full middle name or as the middle initial.
Full name Smith, James A will show display correctly
BUT if the middle name was entered as Smith, James Adam then the last letter of the middle name is displayed as "m” rather than the first letter "A".
I'm currently using this code to get the names separated:
regexp_substr(full_name,'[^, ]+',1,2) First_Name
substr(regexp_substr(full_name,'[^ ]+',1,3),-1) Middle_Initial
The file will need some manual clean up,so 2 first names or extra spaces that kind of thing will be dealt with manually.