In 2005, he should use the new Common Table Expressions for recursive queries. Plus, mima, you should avoid separating the hierarchy and the data in two separate tables. Try this:declare @Locations table (ID int, ParentID int, Location varchar(50))insert into @Locations (ID, ParentID, Location)select 1, 0, 'Europe'UNIONselect 2, 1, 'Western Europe'UNIONselect 3, 2, 'Germany Europe'UNIONselect 4, 3, 'Bavaria'UNIONselect 5, 4, 'Berlin'declare @TargetLocation varchar(50)set @TargetLocation = 'Western Europe';with LocationList as (select Locations.ID, Locations.Location from @Locations Locations where Location = @TargetLocation UNION ALL select Locations.ID, Locations.Location from @Locations Locations inner join LocationList on Locations.ParentID = LocationList.ID)select ID, Locationfrom LocationList
e4 d5 xd5 Nf6