Need a logic to generate serial number for the items having parent and
child mappings
Need a logic to generate serial number for the items having parent and
child mappings.
Below is the sample item mapping( the real system has more than 20 levels)
with four levels.
The generated mapping should be
100- 1
102- 2
104- 3
106 -4
105 -5
109 -6
103- 7
107- 8
The sample data generation scripts
create table #test(Childid int, parentid int, Sno int)
insert into #test (Childid,parentid)
values
(100,0),(102,100),(103,100),(104,102),(105,102),(106,104),(107,103),(109,105)
select * from #test
No comments:
Post a Comment