title: Find chain of columns values - Follow-Up
body: <p>This is the follow-up question of <a href="https://stackoverflow.com/questions/51237878/find-chain-of-columns-values">this</a>.</p>
  
  <p>Table:</p>
  
  <pre><code>create table tbl_test
  (
      col1 int,
      col2 int
  );
  </code></pre>
  
  <p>Records:</p>
  
  <p><strong>edited</strong>:</p>
  
  <pre><code>INSERT INTO tbl_test VALUES(111,112),
                              (112,113),
                              (113,114),
                              (114,111),
                              (115,116),
                              (117,118),
                              (118,119),
                              (119,117), --Added
                              (111,130),
                              (120,121),
                              (122,123),
                              (123,111),
                              (124,111);
  </code></pre>
  
  <p><strong>Query</strong>: I want to find the complete chain col1 and col2 in the form of <code>111-&gt;112-&gt;113-&gt;114-&gt;111</code> 
  (This is complete chain because it starts with <code>111</code> and end with <code>111</code>).</p>
  
  <p><strong>Note</strong>: There might be multiple chain in the table.</p>
  
  <p>Expected Output 2:</p>
  
  <pre><code>col1    col2
  -------------
  111     112
  112     113
  113     114
  114     111 
  117     118
  118     119  
  119     117
  </code></pre>
  
  <p>Tried with gotqn's answer:</p>
  
  <pre><code>WITH DataSource AS
  (
      SELECT col1
            ,col2
            ,0 as level
            ,ROW_NUMBER() OVER(ORDER BY Col1, col2) AS [groupID]
            ,0 as anchorMatched
            ,col1 as startValue
      FROM tbl_test
      WHERE col1 IN (SELECT MIN(col1) FROM tbl_test)
      UNION ALL
      SELECT A.col1
            ,A.col2
            ,level + 1
            ,B.[groupID]
            ,anchorMatched + CASE WHEN A.col1 = B.col2 AND A.col2 = B.startValue THEN 1 ELSE 0 END
            ,b.startValue
      FROM tbl_test A
      INNER JOIN DataSource B
          ON A.col1 = B.col2
      WHERE (anchorMatched = 0 AND A.col1 &lt;&gt; B.startValue)
  )
  SELECT *
  FROM DataSource
  WHERE groupID = 1;
  </code></pre>
  
  <p>But unable to get the second chain.</p>