May 23, 2025 at 12:00 am
Comments posted to this topic are about the item Analyzing Tempdb Spills and Usage Across Recursive Queries
May 25, 2025 at 10:24 pm
I may be mistaken as I have not tested this out
INSERT INTO @Hierarchy
SELECT
h.ID
, h.ParentID
, h.Name
, @Level + 1
FROM
HierarchyBig h
INNER JOIN @Hierarchy t
ON h.ParentID = t.ID;
For this and the temp table, wont this statement run indefinitely once it reaches the final level, if not for the max recursion setting?
----------------------------------------------------
May 26, 2025 at 6:26 am
Hi MMartin1,
We need to seed the root node first.. This has come in screenshot but not in code.
INSERT INTO @Hierarchy (ID, ParentID, Name, Level)
SELECT ID, ParentID, Name, 1
FROM HierarchyBig
WHERE ParentID IS NULL;
Thanks for pointing that out . I’ll request an update to reflect the correct version. Appreciate the feedback!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy