create proc xxx
@id varchar(10)
as
select b.Treeid,b.strCategory,b.IntHave,b.IntTotalInfo 
from CategoryProp as a,NewCategory as b 
where 
a.CategoryId=b.TreeId 
and a.IntParent= @id 
order by a.DisplayOrder Asc调用的时候 exec xxx 'id的值'

解决方案 »

  1.   

    存储过程直接返回结果集的方式:
    -------------------------------------------------------------------
    create procedure sp_test(@id  int)
    as
    select 
        b.*
    from
        CategoryProp a
    inner join
        NewCategory  b
    on
        a.CategoryId = b.TreeId 
    where
        a.a.IntParent= @id
    order by 
        a.DisplayOrder Asc
    GO
      

  2.   

    create proc p_test
    @id int
    as
    select b.* from CategoryProp a,NewCategory b
      where a.CategoryId = b.TreeId
      and a.a.IntParent= @id
      order by a.DisplayOrder Asc
    go
      

  3.   

    create proc
    @id int
    as
    select b.Treeid,b.strCategory,b.IntHave,b.IntTotalInfo 
    from CategoryProp as a,NewCategory as b 
    where 
    a.CategoryId=b.TreeId 
    and a.IntParent= “ & id & ”
    order by a.DisplayOrder Asc
      

  4.   

    create proc yourprocname
         @id varchar(10)
    as
      select b.Treeid,b.strCategory,b.IntHave,b.IntTotalInfo 
      from CategoryProp as a,
           NewCategory as b 
      where a.CategoryId=b.TreeId and a.IntParent= @id order by a.DisplayOrder Asc
      

  5.   

    create procedure sp_test(@id  int)
    as
    select 
        b.*
    from
        CategoryProp a
    inner join
        NewCategory  b
    on
        a.CategoryId = b.TreeId 
    where
        a.a.IntParent= @id
    order by 
        a.DisplayOrder Asc
    GO
      

  6.   

    create proc
    @id int
    as
    select b.Treeid,b.strCategory,b.IntHave,b.IntTotalInfo 
    from CategoryProp as a,NewCategory as b 
    where 
    a.CategoryId=b.TreeId 
    and a.IntParent= @id
    order by a.DisplayOrder Asc