WITH RECURSIVE lines(x, line, remain) AS ( SELECT 1, CASE WHEN substr(v,1,8) = '00000000' THEN 1 ELSE 0 AS line, substr(v, 10) AS remain FROM i UNION ALL SELECT x + 1, CASE WHEN substr(v,1,8) = '00000000' THEN 1 ELSE 0 AS line, substr(remain, 10) AS remain FROM lines WHERE remain != '' ) SELECT line FROM lines