CheeseConQueso CheeseConQueso - 1 year ago 81
SQL Question

Oracle SQL - Parsing a name string and converting it to first initial & last name

Does anyone know how to turn this string: "Smith, John R"

Into this string: "jsmith" ?

I need to lowercase everything with lower()

Find where the comma is and track it's integer location value

Get the first character after that comma and put it in front of the string

Then get the entire last name and stick it after the first initial.

Sidenote - instr() function is not compatible with my version

Thanks for any help!

Answer Source

Start by writing your own INSTR function - call it my_instr for example. It will start at char 1 and loop until it finds a ','.

Then use as you would INSTR.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download