October 9, 2006 at 1:18 pm
declare @n varchar(30)
SELECT @n = 'YARBROUGH, d ALFRED'
SELECT LEFT(@n,CHARINDEX(',',@n)-1) Last,
PARSENAME(REPLACE(STUFF(@n,1,CHARINDEX(',',@n)+1,''),' ','.'),2) First,
PARSENAME(REPLACE(STUFF(@n,1,CHARINDEX(',',@n)+1,''),' ','.'),1) Middle
This work for 1 record but i Need to do a table,something like this. It says
parameter is to large, I believe I need to do a while loop of some sort not sure
declare @n varchar(30)
SELECT @n = 'SELECT RTRIM(ENAME) FROM TFILP'
SELECT LEFT(@n,CHARINDEX(',',@n)-1) Last,
PARSENAME(REPLACE(STUFF(@n,1,CHARINDEX(',',@n)+1,''),' ','.'),2) First,
PARSENAME(REPLACE(STUFF(@n,1,CHARINDEX(',',@n)+1,''),' ','.'),1) Middle
THANKS
October 9, 2006 at 5:06 pm
Did you try like below
SELECT LEFT((RTRIM(ENAME)),CHARINDEX(',',(RTRIM(ENAME)))-1) LastName,
PARSENAME(REPLACE(STUFF((RTRIM(ENAME)),1,CHARINDEX(',',(RTRIM(ENAME)))+1,''),' ','.'),2) FirstName,
PARSENAME(REPLACE(STUFF((RTRIM(ENAME)),1,CHARINDEX(',',(RTRIM(ENAME)))+1,''),' ','.'),1) MiddleName
FROM TFILP
Ram
October 10, 2006 at 1:16 pm
Thanks that worked!!!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply