title: Trying to use break inside a while loop
body: <p>What I am trying for is to exit the loop when a condition meets (if not exists block) while printing the statement; else to continue with the while loop. I get the syntax error:</p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'ELSE'.</p>
  </blockquote>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>WHILE @currentrow &lt; @rows
  BEGIN
  SET @currentrow = @currentrow + 1
  
  SELECT @selectcol = sysid
  FROM @TableVar
  WHERE id = @currentrow
  
  SELECT @sysid =  @selectcol 
  
  IF NOT EXISTS (
  SELECT field_id
  FROM fields
  WHERE sys_id = @sysid
      AND NAME = @field_name
  )
   PRINT cast(@field_name AS VARCHAR) + ' not found in the       business area ' + cast(@sysid AS VARCHAR)
  
  BREAK
  
  ELSE
  
  CONTINUE
  
  [While loop continues]
  </code></pre>