Hi,
I have a column with the first name and last name of a student....and in some cases a middle name.
I am using below query to split the Name.. Its working good but except one condition where Name is like "Anna S.Biermann" .. if middle name has "."(Dot) in it my below query giving wrong results .. In rest all cases query working fine..
In my table we have Name possibilities like below.. Only in last condition where Middle name has Dot in it my query fails.. rest all cases working good..
Barbara Flowers
Allison L Wallace
Anne Renee O'Hara
Anna S.Biermann
Can you please help me in this ?
select **
** ( case LEN(REPLACE(name,' ','')) when LEN(name) - 1 then PARSENAME(REPLACE(name,' ','.'), 2) else PARSENAME(REPLACE(name,' ','.'), 3) end ) as FirstName,
** ( case LEN(REPLACE(name,' ','')) when LEN(name) - 1 then null else PARSENAME(REPLACE(name,' ','.'), 2) end ) as MiddleName,**
** PARSENAME(REPLACE(name,' ','.'), 1) as LastName**
Thank You