Okay, I have gotten my code to this point(I have no idea if it's the most efficient way so far, I'm open to suggestions). There's just one problem. I can't seem to figure out how to sort a tree structure as follows: Main Category SubCategories SubCategoriesetc...
Joe Celko's method was perfect up until this point, but I'm sure it's more a limit of me, than the nested list design. If I try to sort by CatLevel, then it won't maintain the heirarchy. If I sort on LBound, then it just puts it in a heirarchial order, but does not alphabetize. Sort on Category name, and you lose both CatLevel, and the heirarchy. SELECT C1.CategoryId, C1.CategoryName, C1.CategoryDescription, C1.LBound, C1.UBound, Levels.CatLevel FROM tblCategories AS C1, tblCategories AS C2, ( SELECT COUNT(C3.CategoryId) AS CatLevel, C3.CategoryId FROM tblCategories C3, tblCategories C4 WHERE C3.LBound BETWEEN C4.LBound AND C4.UBound GROUP BY C3.CategoryId ) AS Levels WHERE C1.LBound BETWEEN C2.LBound AND C2.UBound AND C2.CategoryId = @CategoryId AND C1.CategoryId = Levels.CategoryId