Set based solution to group multiple rows within a sequence
Not the prettiest query I've ever written, but it seems to get the job done without any recursion. (I've made the assumption that the output needs to be grouped by GroupID and Code.)

WITH starting AS ( --Find each "starting" entry
    SELECT
        d.GroupID,
        d.Code,
        d.StartSeq,
        d.EndSeq,
        d.StartDayNo,
        d.EndDayNo
    FROM SampleData d
        LEFT OUTER JOIN SampleData prev
            ON d.Code = prev.Code
            AND d.GroupID = prev.GroupID
            AND d.StartSeq = prev.EndSeq + 1
    WHERE prev.Code IS NULL
)
SELECT
    s.GroupID,
    s.Code,
    s.StartSeq,
    ISNULL(e.EndSeq, s.EndSeq) AS EndSeq,
    s.StartDayNo,
    ISNULL(e.EndDayNo, s.EndDayNo) AS EndDayNo
FROM starting s
    OUTER APPLY ( --Find the next highest "starting" entry
        SELECT TOP 1
            s2.*
        FROM starting s2
        WHERE s2.Code = s.Code
            AND s2.GroupID = s.GroupID
            AND s2.StartSeq &gt; s.StartSeq
        ORDER BY s2.StartSeq ASC
    ) s2
    OUTER APPLY ( --Find the highest entry less than the next highest "starting" entry
        SELECT TOP 1 *
        FROM SampleData e
        WHERE e.Code = s.Code
            AND e.GroupID = s.GroupID
            AND (e.EndSeq &lt; s2.StartSeq OR s2.Code IS NULL)
        ORDER BY e.EndSeq DESC
    ) e
ORDER BY s.Code, s.StartSeq