a4apple (6/25/2015)
Hmmm... MLM. If that's true, are you using a "uni-level" payout system?
Yes, absolutely... I saw your article Jeff.. My only question is if one account changes its parent account, all its downlines varbinary should also get updated right? is there any such query you can help me with only identifying those accounts that I have to update the Varbinary for? I think it's like asking for an extension of what you already have I guess... or is it only better to delete and reload the entire tree structure???
Yes... updating the varbinary is easy. Just use the recursive CTE that does the initial build to do it. The filter for the primer (first SELECT) in the cte should be the ID of the person who's downline you want to rebuild. Of course, such a change will screw the Nested Sets to the floor but if you're not using those, you can just eliminate that code altogether, even from the initial rebuild.
--Jeff Moden
Change is inevitable... Change for the better is not.