Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2009-09-30 : 22:40:47
|
| Hi,I'm developing a MLM Software. My table structure isTable Name : MemMastFields : CodeNo,SponsorCode,CustNameSample DataCode CustName SponsorCode1 a 02 b 13 c 14 d 35 e 26 f 57 g 4I want the output for Code No. 1Code CustName Level2 b 13 c 14 d 25 e 26 f 37 g 3I've read many post like this in this forum. But I haven't found any final answer or perfect query. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
ravininave
Posting Yak Master
111 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-30 : 23:35:14
|
there is a good example there in the link KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2009-09-30 : 23:47:12
|
quote: Originally posted by khtan there is a good example there in the link KH[spoiler]Time is always against us[/spoiler]
I'm a beginner |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2009-10-01 : 00:00:40
|
| Can u post some code according to my database. It could be helpfull. |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2009-10-01 : 00:11:08
|
| Well, thanx. I solved it by this way. Thanx for ur help.create PROCEDURE findlevel(@IBDNO_1 [numeric](9))AS;with dataAS(Select IBDNo,SP_IBDNo,1 as level from IBDDets Where IBDNo=@IBDNo_1 union all Select s.IBDNo,d.SP_IBDNo,level+1 FROM IBDDets s INNER JOIN data d ON s.SP_IBDNo=d.IBDNo)select * from data order by level |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-01 : 00:39:46
|
that's good  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|