title: SQL query to get full hierarchy path
body: <p>I have a table with three columns NodeId, ParentNodeId, NodeName. for each node I would like to get a full path like "lvl1/lvl2/lvl3..." where lvl1,lvl2 and lvl3 are node names. I found a function which does that at this link <a href="http://www.sql-server-helper.com/functions/get-tree-path.aspx" rel="noreferrer">http://www.sql-server-helper.com/functions/get-tree-path.aspx</a>. but I would like to use CTE OR any other technique for efficiency. Please let me know if it is possible to achieve this in a better way. Thanks in advance.</p>