Versuchen Sie Folgendes:
;WITH items AS (
SELECT EstimateItemID, ItemType
, 0 AS Level
, CAST(EstimateItemID AS VARCHAR(255)) AS Path
FROM EstimateItem
WHERE ParentEstimateItemID IS NULL AND EstimateID = @EstimateID
UNION ALL
SELECT i.EstimateItemID, i.ItemType
, Level + 1
, CAST(Path + '.' + CAST(i.EstimateItemID AS VARCHAR(255)) AS VARCHAR(255))
FROM EstimateItem i
INNER JOIN items itms ON itms.EstimateItemID = i.ParentEstimateItemID
)
SELECT * FROM items ORDER BY Path
Mit Path - Zeilen sortiert nach übergeordneten Knoten
Wenn Sie untergeordnete Knoten nach ItemType sortieren möchten für jedes Level, dann kannst du mit Level spielen und SUBSTRING von Path Spalte....
Hier SQLFiddle mit Beispieldaten