CREATE TABLE Parent (ParentID int, Value1 int) CREATE TABLE Child (ParentID int, ChildID int) INSERT INTO Parent (ParentID, Value1) VALUES(1, 1), (2, NULL), (3, 3), (4, NULL), (5, 5), (6, 6), (7, 1) INSERT INTO Child (ParentID, ChildID) VALUES(1, 11), (2, 21), (2, 22), (3, 31), (3, 32), (3, 33), (4, 41), (4, 42), (4, 43), (4, 44), (6, 61), (6, 62), (6, 63), (6, 64), (6, 65), (6, 66), (7, 77)