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

Generazione di righe in base al valore della colonna

Modo non ricorsivo:

SELECT *
FROM tab t
CROSS APPLY (SELECT n
             FROM (SELECT ROW_NUMBER() OVER(ORDER BY 1/0) AS n
                   FROM master..spt_values s1) AS sub
             WHERE  sub.n <= t.Quantity) AS s2(Series);

db<>demo violino