I am using SQL Server 2012, I have a table called [Area]. This table contains a PK and a ParentPK. The ParentPk references the PK from the same [Area] table recursively. If there is no parent, then null is filled in for ParentPk.
Pk ParentPk
----------------
1 null
2 null
3 1
4 3
...
I know that the ancestor-child relationship is exactly 3 levels deep. In the above example, The Pk:4 has its parentPk:3 and grandParentPk:1.
I want to be able have a SELECT query be in the form:
SELECT GrandParentPk, ParentPk, ChildPk
...
...
...
where ChildPk = <childPk>
Is there a non stored procedure, non recursive solution to achieve this?