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
- Asp.net insert, Edit, update, delete data in gridview
- 3 tier architecture example in asp.net with C#
- Introduction to Object Oriented Programming Concepts (OOPS) in C#.net
- jQuery 360 Degrees Image Display Plugins Examples with Tutorial
- 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
- 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
- Interview Questions in ASP.NET,C#.NET,SQL Server,.NET Framework
- Simple login form example in asp.net Check Username and Password availability in database
- Ajax ModalPopUpExtender Example to edit the gridview row values in asp.net
- Ajax Cascading Dropdownlist Sample with database using asp.net