While loop example - T-Sql Stored Procedure

While loop example - T-Sql Stored Procedure

In most of the queries we are using while loops for fetching, inserting,deleting records. In this example i am showing a while loop example in the stored procedure.

create procedure sp_WhileLoop
as
begin
declare @count int
set @count=1
  while(@count<=5)
  begin
     print @count
     set @count=@count+1
  end
end


Output:

1
2
3
4
5
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar