This is called an ancestry tree. I have an example of such a query on my blog. You can check it at the following link, just look at the ancestry section.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events