I have a column name Parent and Child in table Example and Below is the Table Data
| Parent |
you can simply use graph processing introduced in SQL Server 2017. here is an example
https://www.red-gate.com/simple-talk/sql/t-sql-programming/sql-graph-objects-sql-server-2017-good-bad/