Bird
0
0

Which of the following is the correct way to begin a WHILE loop in a SQL stored procedure?

easy📝 Syntax Q3 of 15
SQL - Stored Procedures and Functions
Which of the following is the correct way to begin a WHILE loop in a SQL stored procedure?
ALOOP WHILE @count < 10
BWHILE @count < 10 BEGIN
CFOR @count = 1 TO 10
DREPEAT WHILE @count < 10
Step-by-Step Solution
Solution:
  1. Step 1: Understand WHILE syntax

    The correct syntax to start a WHILE loop in SQL Server is: WHILE condition BEGIN ... END.
  2. Step 2: Analyze options

    WHILE @count < 10 BEGIN correctly uses WHILE @count < 10 BEGIN. Options B, C, and D use invalid or unsupported syntax in SQL Server.
  3. Final Answer:

    WHILE @count < 10 BEGIN -> Option B
  4. Quick Check:

    WHILE loops start with 'WHILE condition BEGIN' [OK]
Quick Trick: WHILE loops start with 'WHILE condition BEGIN' [OK]
Common Mistakes:
  • Using LOOP or REPEAT keywords which are not valid in SQL Server
  • Confusing FOR loops with WHILE loops
  • Omitting BEGIN after WHILE condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes