Which of the following queries is more efficient?
DECLARE @i int
SET @i = 1
WHILE (@i < 40)
BEGIN
INSERT INTO table (number)
VALUES (@i)
SET @i = @i + 1
END
or
INSERT INTO table (number)
SELECT n
FROM anothertable
WHERE n <= @i
anothertable
is a table with a column n
with numbers from 1..100.
Please help