MichaelF81
Programmer
I have a table with 3 fields, em_id (vharchar 100), name_first (VarChar 50), name_last (varchar 50).
em_id has name info like "doe, john". I need to split the data and make name_first and name_last hold that info.
does not work, and it always returns
Ideas?
"Adults are just obsolete children and the hell with them." - Dr. Seuss
em_id has name info like "doe, john". I need to split the data and make name_first and name_last hold that info.
Code:
use wbtest
Update afm.em
Set name_last = Left(em_id, CharIndex(', ', em_id) - 1),
name_first = LTrim(Right(em_id, Len(em_id)) - CharIndex(', ', em_id))
WHERE name_first is null and name_last is null
GO
does not work, and it always returns
Server: Msg 536, Level 16, State 3, Line 1
Invalid length parameter passed to the substring function.
The statement has been terminated.
Ideas?
"Adults are just obsolete children and the hell with them." - Dr. Seuss