- idioms loop the SET STATISTICS the TIME the ON the SET STATISTICS the IO the ON the GO the WITH cte_a the AS ( the SELECT [ idiom ] , the CAST ( [ idiom ] the AS NVARCHAR ( MAX )) the AS the cpath, [ FirstWord ] , [ LastWord ] , . 1 the AS the ilevel, 0 the AS isrecycle the FROMdbo.cyzd the WHERE phrase = ' nation is ' the UNION ALL the SELECT S. idiom, the CAST (p.cpath + ' / ' + S. [ idiom ] the AS NVARCHAR ( MAX )) the AS the cpath, S. [ FirstWord ] , S . [ LastWord ] , p.ilevel + . 1 the AS the ilevel, the CASE the WHEN S. idiom ='国将不国' THEN 1 ELSE 0 END AS isrecycle FROM dbo.cyzd AS s INNER JOIN cte_a AS p ON p.lastword = s.firstword WHERE p.ilevel + 1 <= 10 AND CHARINDEX(s.成语, p.cpath) IN ( 0, 1 ) AND p.isrecycle = 0) SELECT * FROM cte_a WHERE cte_a.isrecycle = 1;