Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Crea una tabella temporanea con un intervallo di numeri

WITH    q AS
        (
        SELECT  startId, endId
        FROM    ranges
        UNION ALL
        SELECT  startId + 1, endId
        FROM    q
        WHERE   startId < endId
        )
SELECT  startId
FROM    q
OPTION  (MAXRECURSION 0)