with MyData as ( select ID ,Name ,ParentPath = CONVERT(varchar(max), '/') ,ItemPath = convert(varchar(max), '/' + name) from dbo.Items where 1=1 and ParentID = '00000000-0000-0000-0000-000000000000' union all select i.ID ,i.Name ,ParentPath = d.ItemPath ,ItemPath = convert(varchar(max), d.ItemPath + '/' + i.Name) from dbo.Items i inner join MyData d on d.ID = i.ParentID ) select ID ,ItemPath from MyData order by ItemPath
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.