i have a table 'MEMBERSHIP' Which contain follwing field (MEMBER_CODE,MEMBER_NAME,RANK_POS,INTRODUCER_CODE} NOW I HAVE TO CHAIN MEMBER LIKE A INTRODUCE BY B (A-MEMBER_CODE,B WILL INTRODUCER) C INTRODUCE BY A D INTRODUCE BY C SO I I HAVE TO FIND OUT B CHAIN IT WILL BE DISPLAY LIKE THIS A,C,D INFORMATION
There's a good explanation of how a recursive CTE should do what you want it to do [here] :
http://msdn.microsoft.com/en-au/library/ms186243(v=sql.105).aspx I suppose the corollary questions will be: How many levels deep will the chain of members and introducers go? How many members all told, do you need your system to be able to accommodate. If you have a million members and there are 50 levels of introduction, the above solution might not be an appropriate option from a performance point of view.