title: Loop never ends in SQL Server using While Exists
body: <pre><code>While Exists (Select * From Col Where Depth Is Null)
      Update T
      Set T.Depth = P.Depth + 1,
          T.Lineage = P.Lineage + LTrim(Str(T.ParentId, 6, 0)) + '/'
      From Col T
      Join Col P On T.ParentId = P.Id
      Where
          P.Depth &gt;= 0
          And P.Lineage Is Not Null
          And T.Depth Is Null
  </code></pre>