Dette vil understøtte over 7.400 gentagelser for ethvert individuelt job (på mit system). Hvis du har brug for mere, kan du bruge en anden systemtabel eller en krydssammenføjning.
DECLARE @d TABLE (Job INT, Quantity INT, Status VARCHAR(12), Repeat INT);
INSERT @d SELECT 1, 100, 'OK' ,2
UNION ALL SELECT 2, 400, 'HOLD',0
UNION ALL SELECT 3, 200, 'HOLD',1
UNION ALL SELECT 4, 450, 'OK' ,3;
WITH x AS
(
SELECT TOP (SELECT MAX(Repeat)+1 FROM @d) rn = ROW_NUMBER()
OVER (ORDER BY [object_id])
FROM sys.all_columns
ORDER BY [object_id]
)
SELECT * FROM x
CROSS JOIN @d AS d
WHERE x.rn <= d.Repeat + 1
ORDER BY Job;