Users Pricing

forum

Home Forums How can I use select in a SQL Server while loop? – MindStick

How can I use select in a SQL Server while loop?

Anonymous User 2699 22 Oct 2013

How can I use select in a SQL Server while loop? Below have my demo code: -

 declare @loopVal integer

 set @loopVal =1
 while (@loopVal <10)
 begin
   select @loopVal as m;
   set @loopVal =@loopVal +1
 END 


I want it to return all select results in one table but it will returns 10 separate table ... how can I achieve my task?

Please help me out…!!!!



1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md