continue

Description

Restarts the while loop. continue is often activated by an if test.

Syntax

while boolean_expression 
		statement 
	break 
		statement 
continue

Examples

Example 1

If the average price is less than $30, double the prices. Then, select the maximum price. If the maximum price is less than or equal to $50, restart the while loop and double the prices again. If the maximum price is more than $50, exit the while loop and print a message:

while (select avg (price) from titles) < $30 
begin 
  update titles 
  set price = price * 2 
  select max (price) from titles 

  if (select max (price) from titles) > $50 
     break 
  else 
     continue 
end 

begin 
print "Too much for the market to bear" 
end

Usage

continue restarts the while loop, skipping any statements after continue.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

No permission is required to use continue.

See also

Commands break, while