title: T-SQL: Cursor iteration not stopping at @@FETCH_STATUS=-1
body: <p>I’ve created a simple cursor in a stored procedure. The cursor simply iterates all the rows of a table.</p>
  
  <p>From my output it seems that the iterator fetches n+1 rows.</p>
  
  <p>I’ve tried a to break the while loop of the iteration but this doesn’t solve the issue.
  How come?</p>
  
  <pre><code>ALTER PROC spInsertNewCategory --spInsertNewCategory '-1','-1'
  @categoryName NVARCHAR(80),
  @categoryInfo NVARCHAR(80)
  AS 
  BEGIN
  
      DECLARE @siteLanguage_id      INT
      DECLARE @lang_id              INT
      DECLARE @default_siteLanguage INT
  
      DECLARE cr_siteLanguage       CURSOR
      FOR 
      SELECT sl.siteLanguage_id, sl.lang_id, sl.default_siteLanguage 
      FROM siteLanguage sl
  
  
      OPEN cr_siteLanguage
          FETCH NEXT FROM cr_siteLanguage
          INTO @siteLanguage_id,@lang_id,@default_siteLanguage
          PRINT '@siteLanguage_id: '+ CAST(@siteLanguage_id AS NVARCHAR(3))+' fetch: '+ CAST(@@FETCH_STATUS AS NVARCHAR(5))
  
          WHILE (@@FETCH_STATUS = 0)
              BEGIN
              IF (@@FETCH_STATUS=-1)
                  BEGIN
                  PRINT 'in if -1'
                  BREAK
                  END
              FETCH NEXT FROM cr_siteLanguage
              INTO @siteLanguage_id,@lang_id,@default_siteLanguage
              PRINT '@siteLanguage_id: '+ CAST(@siteLanguage_id AS NVARCHAR(3))+' fetch: '+ CAST(@@FETCH_STATUS AS NVARCHAR(5))
              END
      CLOSE cr_siteLanguage
      DEALLOCATE cr_siteLanguage 
  
      SELECT * FROM siteLanguage
  END
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/2bXcw.jpg" alt="enter image description here">
  <img src="https://i.stack.imgur.com/scOsG.jpg" alt="enter image description here"></p>