Need a logic to generate serial number for the items having parent and child mappings.
Below is the image showing 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
Any help is appreciated.
Please use Marked as Answer if my post solved your problem and useVote As Helpful if a post was useful.