;) as varchar(max)) as ssort from Category where ID = '123' union all select t.*, ) as varchar(max)) from catChild, Category t where catChild.ID = t.ParentID) ' order by ssort,Sort ;with cte as ( level, ) as varchar(max)) as ssort from Category where…