title: HierarchyId Has Descendants Query
body: <p>Given the following schema and data:</p>
  
  <pre><code>CREATE TABLE ##Nodes
  (
      NodeCode hierarchyid,
      NodeName varchar(10)
  
  )
  
  INSERT INTO ##Nodes VALUES ('/','RootNode')
  INSERT INTO ##Nodes VALUES ('/1/','Node1')
  INSERT INTO ##Nodes VALUES ('/1/1/','Node1.1')
  INSERT INTO ##Nodes VALUES ('/2/','Node2')
  INSERT INTO ##Nodes VALUES ('/3/','Node3')
  INSERT INTO ##Nodes VALUES ('/3/1/','Node3.1')
  INSERT INTO ##Nodes VALUES ('/4/','Node4')
  </code></pre>
  
  <p>How can I get the following result:</p>
  
  <pre><code>NodeCode | NodeName | HasDescendants
  /, RootNode, true
  /1/, Node1, true,
  /1/1/, Node1.1, false
  /2/, Node2, false
  /3/, Node3, true
  /3/1/, Node3.1, false
  /4/, Node4, false
  </code></pre>