WHILE LOOP IN SQL SERVER

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 734  View(s)
Ratings:
Rate this:
 I want to use While Loop in Sql Server please help me
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: WHILE LOOP IN SQL SERVER

    A while loop will check the condition first and then executes the block of Sql Statements within it as along as the condition evaluates to true.
    Syntax:
    WHILE Condition
    BEGIN
    Sql Statemen

    DECLARE @site_val INT;

    SET @site_val = 0;

    WHILE @site_val <= 10

    BEGIN

    PRINT 'Inside WHILE LOOP ON Mindstick.com';

    SET @site_val = @site_val + 1;

    END;

    PRINT '_________________________________';

    PRINT 'Done WHILE LOOP ON Mindstick.com';

    PRINT '_________________________________';

    GO

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!