with as 递归

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

with accountrp AS(
  SELECT TOP 1 uid,uaccountrpid,ccode from t_accountrp where ccode='S1409170006' 
	UNION ALL
	SELECT  t_accountrp.uid,t_accountrp.uaccountrpid,t_accountrp.ccode 
		from accountrp inner join t_accountrp on accountrp.uaccountrpid=t_accountrp.uid
 )select  * from accountrp ORDER BY ccode;