• thanks chris for your reply . i need a recursive way to deal with serial hierarchy.

    the problem is the serial can be like this.

    DECLARE @Result TABLE (Serial nvarchar(10),Title varchar(20))

    INSERT INTO @Result

    SELECT '1.1','a' UNION ALL

    SELECT '1.2.1','b' UNION ALL

    SELECT '1.2.2','C' UNION ALL

    SELECT '1.2.3','G' UNION ALL

    SELECT '1.11','B' UNION ALL

    SELECT '2.3','B' UNION ALL

    SELECT '2.11','B' UNION ALL

    SELECT '2.2','C' UNION ALL

    SELECT '1.5','E' UNION ALL

    SELECT '1.3','E'

    SELECT * FROM @Result ORDER BY serial