February 7, 2014 at 4:21 pm
I should have asked this before. How many levels are you expecting?
February 8, 2014 at 3:32 pm
Dear Sir
In real data It goes up to 11 level . I would say not more than 12.
I have tried this but this is wrong anyway. It updates only for top parent not for the sub level.
drop table #table
go
create table #table (Value varchar(max), [ParentID] int)
go
create index ix_ParentID on #table (ParentID)
go
Insert into #table
select cast([ParentID] as varchar(5)) + '\' +
cast([childID] as varchar(5)) value, [ParentID]
from staging.Hierarchy
While (@@ROWCOUNT > 0)
Begin
update a
set a.value = cast(b.[ParentID] as varchar(5)) + '\' + a.value,
a.[ParentID] = b.[ParentID]
from #table a inner join staging.hierarchy b on a.[ParentID] = b.[childID]
End
insert into Hierarchy (Value , [ParentID] )
select * from #table
select * from staging.Hierarchy
February 14, 2014 at 10:27 am
Dear Sir
Is any possible solution for this sir..Please
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply