SQL SERVER2005及其以上版本树形结构实现

来源:互联网 发布:淘宝直播小陈珍珠 编辑:程序博客网 时间:2024/05/17 11:57
 WITH #Jgxx(JGBM, JGMC, JGJB, CJ)
AS
(select JGBM, JGMC, JGJB, 0 as CJ from SYS_ZCJG where JGBM = @sInTjjg
union all
select B.JGBM, B.JGMC, B.JGJB, A.CJ + 1 as CJ
from #Jgxx A inner join SYS_ZCJG B on A.JGBM = B.SJJGBM
)
select *
into #tempJgxx
from #Jgxx where JGJB not in('1', '2', '3')
原创粉丝点击