I have a table with such a structure.
ElementId | ParentId
-------------------
1 | NULL
2 | 1
3 | 2
4 | 3
Suppose the current item has an identifier of 4. I want to select all the parent IDs. The result should be: 3, 2, 1
How can i do this? DB - MSSQL
source
share