create proc aa
@cateName varchar(200)
as
DECLARE @ID int
SET @ID =(select top 1 cate_id from xo_category_description where cate_name=@cateName)
;WITH T AS
(
SELECT xo_category.cate_id,xo_category.parent_id,xo_category.date_add
FROM xo_category
WHERE cate_id = @ID
UNION ALL
SELECT A.cate_id ,a.parent_id,a.date_add
FROM xo_category AS A JOIN T AS B ON A.parent_id = B.cate_id
)
SELECT * FROM T ORDER BY cate_id