Thanks dj, your suggestion helped me out. I did solve it:
CREATE PROC dbo.ShowHierarchyXML2
(
@Root int,
@MaxLevels int
--@SortOrderNumIn int = 0
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @ChildNodeID int,@SortOrderNum int,@curNodeLabel varchar(30), @curChildNodeID int, @curParentNodeID int, @curPriorParent...