How can INSERT INTO a table 300 times within a loop in SQL?

后端 未结 5 598
半阙折子戏
半阙折子戏 2021-02-02 06:35

I would like to insert a value retrieved from a counter in SQL and repeat it 300 times.

Something like:

DECLARE @Counter = 0;

-- BEGIN Loop 
    SET @Co         


        
5条回答
  •  难免孤独
    2021-02-02 06:57

    DECLARE @first AS INT = 1
    DECLARE @last AS INT = 300
    
    WHILE(@first <= @last)
    BEGIN
        INSERT INTO tblFoo VALUES(@first)
        SET @first += 1
    END
    

提交回复
热议问题