create proc p_qry
@parent varchar(10)
as
if @parent is null
select * from 表 where parent is null
else
select * from 表 where parent=@parent
go

解决方案 »

  1.   

    参数为(null)
    结果显示:11  (null)   C怎么只有一个结果。
    不是应该01     (null)     A      ...
    06     (null)     B      ...
    11     (null)     C      ...
    12     (null)     D      ...另外你说不要子树枝什么意思?
      

  2.   

    create proc p_qry
    @parent varchar(10)
    as
    if @parent is null
    select * from 表 where parent is null
    else
    select * from 表 where parent=@parent 
                 and item not in (select parent from 表)
    go
      

  3.   

    create proc p_qryItem
    @parent varchar(10)
    as
    select * from item A
    where A.parent=@parent and A.self not in(select parent from item where parent=A.self)
    order by parent,self
      

  4.   

    http://community.csdn.net/Expert/topic/3511/3511848.xml?temp=.1927301