title: How can I create a loop on an UPDATE statement that works until there is no row left to update?
body: <p>Assume that I have thousands of rows to update.</p>
  
  <p>And I plan to do the update iteratively; by only updating 1000 rows per iteration. </p>
  
  <p>And I want to iterate until there are no rows left to update.</p>
  
  <p>How can I run the T-SQL script below until there is no row to update?</p>
  
  <pre><code>-- TODO: Create a loop so that it exists when there is no ROW left to be updated; 
  -- how can I do it?
  
  UPDATE tableToUpdate
  SET IsVegetable = 1
  WHERE Id IN
                 (SELECT TOP 1000 Id
                  FROM tableToUpdate
                  WHERE Date = '2011-07-23 14:00')
  
  -- Loop ends
  </code></pre>