sqlserver树形显示

来源:互联网 发布:mac下载dota2 编辑:程序博客网 时间:2024/05/16 17:02
 with v_bm_dict_lab as(select *,cast(id as int ) px,cast(id as int ) px2 from BM_DICT_Lab where pid=0 union all select a.*,b.px,b.px2+ltrim(a.id) from BM_DICT_Lab a join v_bm_dict_lab b on a.pid=b.id )select * from v_bm_dict_lab order by px,px2