title: Cursor FETCH failed. @@FETCH_STATUS is -1
body: <p>Transactions table definition :</p>
  
  <pre><code>create table Transactions ([ID] [int] NOT NULL, [Value] [int] NOT NULL)
  </code></pre>
  
  <p>Let's insert some records.</p>
  
  <pre><code>INSERT INTO Transactions Values(1,100)
  INSERT INTO Transactions Values(2,10)
  </code></pre>
  
  <p>This is how I am using cursor</p>
  
  <pre><code>create table #Tmp_Transactions ([ID] [int] NOT NULL, [Value] [int] NOT NULL)
  INSERT INTO #Tmp_Transactions SELECT * FROM Transactions WHERE Value&gt;100
  DECLARE @rowcount int
  SET @rowcount = @@rowcount
  PRINT @rowcount
  DECLARE @ID int
  DECLARE txcursor CURSOR FOR SELECT ID FROM #Tmp_Transactions
  OPEN txcursor
  FETCH NEXT FROM txcursor INTO @ID
  PRINT @@FETCH_STATUS ---//prints -1
  
  CLOSE txcursor
  DEALLOCATE txcursor
  drop table #Tmp_Transactions
  </code></pre>
  
  <p>----- prints</p>
  
  <pre><code>(0 row(s) affected)
  0
  -1
  </code></pre>