title: How to manually break the cursor within a while loop?
body: <p>If the while loop hits the break command it comes out of the loop and  if cursor hit the break command, how can it break entirely out of the while loop?</p>
  <p>For example:</p>
  <pre><code>DECLARE @CursorTest TABLE 
  (
      idcol INT ,
      fld1 INT,
      fld2 INT,
      fld3 CHAR(800)
  )
  
  INSERT INTO @CursorTest (fld1, fld2, fld3)
  
  SELECT 1, RAND() * 100 * DATEPART(ms, GETDATE()), LEFT(REPLICATE(CAST(NEWID() AS VARCHAR(36)),30),800)
  
  
  DECLARE @Variable1 INT, @Variable2 INT
  DECLARE CursorName CURSOR FAST_FORWARD
  FOR
  SELECT idcol    FROM @CursorTest    
  OPEN CursorName
  FETCH NEXT FROM CursorName  INTO @Variable1
  WHILE @@FETCH_STATUS = 0
  BEGIN   
      if (@Variable1 =10) 
      BEGIN
          BREAK
      END 
      PRINT CAST(@Variable1 AS VARCHAR(5))
  
  FETCH NEXT FROM CursorName  INTO @Variable1
   
  END
  CLOSE CursorName
  DEALLOCATE CursorName
  </code></pre>