Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Generieren von Zeilen basierend auf dem Spaltenwert

Nicht rekursiver Weg:

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<>Fiddle-Demo