Cybercrux

Everything is achievable through technology

While

Example 1

DECLARE @site_value INT;
SET @site_value = 0;
WHILE @site_value <= 10
BEGIN
PRINT 'Inside WHILE LOOP on TechOnTheNet.com';
SET @site_value = @site_value + 1;
END;
PRINT 'Done WHILE LOOP on TechOnTheNet.com';
GO

Example 2

DECLARE contacts_cursor CURSOR FOR
SELECT contact_id, website_id
FROM contacts;
OPEN contacts_cursor;
FETCH NEXT FROM contacts_cursor;
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM contacts_cursor;
PRINT 'Inside WHILE LOOP on TechOnTheNet.com';
END;
PRINT 'Done WHILE LOOP on TechOnTheNet.com';
CLOSE contacts_cursor;
DEALLOCATE contacts_cursor;
GO

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s