title: A While loop inside a cursor's while loop - SQL
body: <pre><code>declare @i int
  declare @skool float
  
  declare schoolCursor cursor for  
  select distinct choice from tempstuas
  
  open schoolCursor
  fetch next from schoolCursor into @skool
  while @@fetch_status = 0
  begin
          while @i &lt; 20
              begin
                  update top(1) tempstuas set cnt=@i where cnt = '' and cat = 1 and choice=@skool
                  update top(1) tempstuas set cnt=@i where cnt = '' and cat = 2 and choice=@skool
                  update top(1) tempstuas set cnt=@i where cnt = '' and cat=3 and choice=@skool
  
                  set @i = @i + 1
              end
          fetch next from schoolCursor 
  end
  close schoolCursor
  deallocate schoolCursor
  </code></pre>
  
  <p>This is basically going through a cursor that returns an individual location number. The location number is stored as a variable from the cursor which I need to use inside a while loop that iterates through a specific amount of times (20). What I am returned is just the cursor going on for the whole list of location numbers but does not iterate through the while loop with the update statements.</p>