Is While Loop Returns Only One Value in Sql

Posted by Sabarimahesh under Sql Server on 3/20/2012 | Points: 10 | Views : 1461 | Status : [Member] | Replies : 7
While(@input=select * from tablename)
Begin
End

Is this Possible

ANd Give Me Some More Examples

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M



Responses

Posted by: Naraayanan on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
No,While Loop return only One Value(last value of your table) .


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/22/2012 [Member] Silver | Points: 25

Up
0
Down

While loop executes till the condition is found to be true.

Thanks,
Sanjay

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Sksamantaray:
can you Give a Example for my Reference




Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Naraayanan
can you Give a Example for my Reference

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/22/2012 [Member] Silver | Points: 25

Up
0
Down
Hi ,
Try this.
Declare @var int=0

while(@var<10)
begin
set @var=@var+1
print @var

end


Thanks,
Sanjay

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Veerac85 on: 3/27/2012 [Member] Starter | Points: 25

Up
0
Down
you could something like this

declare @EmpID int

select @EmpID = min( EmployeeID) from tblEmployee

while @EmpID is not null
begin
print @EmpID
select @EmpID = min( EmployeeID ) from tblEmployee where EmployeeID > @EmpID
end

if you want more examples, you could go tohttp://technico.qnownow.com/2012/03/27/while-loop-with-break-and-continue-keywords-goto-statement-in-sql-server/

Regards
Veera

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/28/2012 [Member] Bronze | Points: 25

Up
0
Down
Veerac85

Thank You


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response