HiI'm trying to write a recursive CTE on the following table so that I can create a structure of the hierarchy that exists there. The problem is that my CTE is only returning the top level (e.g. where parentID IS NULL) and misses out all the sub-levels.Can anyone show me what I'm doing wrong please??DECLARE @tmp TABLE ( [ID] [int] IDENTITY(1,1) NOT NULL, [parentID] [int] NULL, [SubjectName] [nvarchar](200) NOT NULL );INSERT INTO @tmp (parentID, SubjectName) VALUES (NULL, 'ASP.NET');INSERT INTO @tmp (parentID, SubjectName) VALUES (NULL, 'SQL Server');INSERT INTO @tmp (parentID, SubjectName) VALUES (1, 'GridViews');INSERT INTO @tmp (parentID, SubjectName) VALUES (1, 'DataSets');INSERT INTO @tmp (parentID, SubjectName) VALUES (1, 'DataTables');INSERT INTO @tmp (parentID, SubjectName) VALUES (2, 'CTEs');INSERT INTO @tmp (parentID, SubjectName) VALUES (2, 'Table Variables');WITH Topics (ID, ParentID, SubjectName, Level)AS(SELECT e.ParentID, e.ID, e.SubjectName, 0 AS LevelFROM @tmp AS eWHERE ParentID IS NULLUNION ALLSELECT e.ParentID, e.ID, e.SubjectName, Level + 1FROM @tmp AS e INNER JOIN Topics AS t ON e.ParentID = t.ID)SELECT ID, ParentID, SubjectName, LevelFROM Topics