http://blog.csdn.net/xluzhong/articles/340928.aspx

解决方案 »

  1.   

    http://blog.csdn.net/zjcxc/archive/2003/12/29/20073.aspx
      

  2.   

    --写如下处理函数
    create function f_cid(
    @id int
    )returns @re table(ProductClass_ID int,[level] int)
    as
    begin
    declare @l int
    set @l=0
    insert @re select @id,@l
    while @@rowcount>0
    begin
    set @l=@l+1
    insert @re select a.ProductClass_ID,@l
    from ProductClass a,@re b
    where a.Parent_ID=b.ProductClass_ID and b.[level]=@l-1
    end
    return
    end
    go--删除某个id使用下面的语句,删除id=2的:
    delete a from ProductClass a,f_cid(2) b where a.ProductClass_ID =b.ProductClass_ID
      

  3.   

    http://community.csdn.net/Expert/TopicView.asp?id=3799658