For loop in Sql Server
how to use For loop in SQL Server?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishnujeet KumarRank #1,019 · 1.9K reputationPosted Nov 5, 2012, 8:26 PM EST
DECLARE @intTable INT
SET @intTable = 5
WHILE (@intTable <=50)
BEGIN
PRINT @intTable
SET @intTable = @intTable + 5
END
GO
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Nov 5, 2012, 7:45 PM EST
Rajeev KumarRank #1,334 · 1.3K reputationPosted Jul 10, 2023, 3:42 AM EDT
There is no concept to use for loop SQL. You have to use only while loop.