While loop in SQL Server 2008

In this post, we will discuss how to use while loop in SQL server 2008.

Also, you can check out my previous posts on

Difference between primary key and unique key in SQL Server,

Difference between primary key and foreign key in SQL server 

Like operator examples in SQL Server 2008.

Below is the syntax to use While Loop in SQL Server:

DECLARE @flag INT

SET @flag = 0

WHILE @flag <= 5

BEGIN

SET @flag = @flag + 1

PRINT ‘You are in ‘ + CAST (@flag AS NVARCHAR(10)) +’ Loop’

END


The out put will come as shown in the figure below.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply