For Loop In SQL Queries
How to apply For loop in SQL queries?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Santhosh Kumar JayaramanPosted Oct 8, 2012, 1:28 AM
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