Hi,
Hope this query will get the result. Since update is involved please try this with sample development data before testing with real records. If you are using 2012 please try with Lead Functions which will get rid of this CTE.
create table #tempDha(Id varchar(50),Code int,Parent varchar(50))
insert into #tempDha values('Nokia',610, 'cube')
,('Invest' ,240 ,'ahnc')
,('Invest', 241 ,'hnnc')
,('apple' ,500 ,'sumo')
,('Iphone', 210 ,'robert' )
with cte as
(
select dense_rank()over(PARTITION by Id order by code) as Ra,* from #tempDha)
update t set t.Parent= t.Parent + ' '+ t.Id
from #tempDha t join cte c on t.Id=c.Id
where Ra>1
Thanks
Dharani