DECLARE @loop INT
SET @loop = 0
WHILE @loop <= 10
SET @loop = @loop + 1
By: Suresh Dasari Nov 6, 2012
Here I will explain how to use while loop in SQL Server stored procedure with example.
In previous articles I explained Find First and last day of current month in SQL, Convert Rows to Columns in SQL, Joins in SQL Server and many articles relating to SQL Server Now I will explain how to use while loop in SQL Server stored procedure with example.
To use while loop in stored procedure we need to write the query like this
If we run above query we will get output like as shown below
In this way we can use while loop in SQL Server.
Other Related Posts
- 3 tier architecture example in asp.net with C#
- Asp.net insert, Edit, update, delete data in gridview
- Introduction to Object Oriented Programming Concepts (OOPS) in C#.net
- Interview Questions in ASP.NET,C#.NET,SQL Server,.NET Framework
- Introduction to WCF - WCF tutorial | WCF Tutorial - Windows Communication Foundation | WCF Example | WCF Sample code in asp.net 3.5 | Basic WCF Tutorial for Beginners
- jQuery 360 Degrees Image Display Plugins Examples with Tutorial
- how to insert images into database and how to retrieve and bind images to gridview using asp.net (or) save and retrieve images from database using asp.net
- Simple login form example in asp.net Check Username and Password availability in database
- Asp.net WebService or Creating and Consuming WebService in asp.net or Create and call webservice in asp.net or how to create webservice and how to use webservice in asp.net
- Ajax ModalPopUpExtender Example to edit the gridview row values in asp.net