----------This is loop example in sql server---------------- Declare @maxNo int Declare @i int set @maxNo=4 set @i=1 print 'Output' ---Use while loop---- while(@i<=@maxNo) begin print @i set @i=@i+1 end --output------ 1 2 3 4
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Declare @maxNo int
Declare @i int
set @maxNo=4
set @i=1
print 'Output'
---Use while loop----
while(@i<=@maxNo)
begin
print @i
set @i=@i+1
end
--output------
1
2
3
4