For Loop In SQL Queries
How to apply For loop in SQL queries?
1 Answer
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
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Oct 7, 2012, 9:28 PM EDT
See the below sql statements
declare @maxid int
declare @id int=1
select @maxid=max(id) from table1
While (@id<@maxid)
BEGIN
--Do SOMETHING LINE1
--Do SOMETHING LINE2
END