Select statement to return parent and infinite children

So referencing this answer: SQL Server CTE Parent Child recursive Here’s a working version with your schema: Table Creation Script CREATE TABLE YOUR_TABLE ([ID] int, [ParentID] int, [Name] varchar(21)) ; INSERT INTO YOUR_TABLE ([ID], [ParentID], [Name]) VALUES (1, NULL, ‘A root’), (2, NULL, ‘Another root’), (3, 1, ‘Child of 1’), (4, 3, ‘Grandchild of 1’), … Read more