title: Using fetch next with where in cursor
body: <p>Is there any option to search inside cursor?<br>
  For example: I have a table(MyTable) with row number and value,<br>
  that I want to copy to another table(TestTable),<br>
  but let's say that if there was a value >= 5 then the next value,<br>
  that I want to copy should be &lt;= 3.<br>
  I can use something like this:</p>
  
  <pre><code>create table TestTable
  (row tinyint,
  value tinyint)
  
  declare @row tinyint, @value tinyint, @trigger bit
  declare test_cursor cursor fast_forward for
  select row,value from MyTable order by row
  open test_cursor
  fetch next from test_cursor into @row,@value
  set @trigger = 0
  while @@FETCH_STATUS = 0
      begin
          if @trigger = 0
              begin
                  insert into TestTable values (@row,@value)
                  if @value &gt;= 5 set @trigger = 1
              end
          else if @value &lt;= 3 
              begin
                  insert into TestTable values (@row,@value)
                  set @trigger = 0
              end
          fetch next from test_cursor into @row,@value
      end
  close test_cursor
  deallocate test_cursor  
  </code></pre>
  
  <p>That will work, but my question is: is there an any way to search inside cursor<br>
  for the next falue that &lt;= 3 once trigger = 1,<br>
  instead of fetching next row over and over every time?  </p>