http://blog.csdn.net/aqgsh/article/details/8493919
declare @pid int;
set @pid =2;
declare @pid int;
set @pid =2;
with a as(
select * from dbo.T_Category where id=@pid
union all
select c.* from a , dbo.T_Category c where c.ParentId=a.id
)
select * from a