title: Does GetDate() get re-evaluated for each iteration within loop within a transaction?
body: <p>I have a scenario where I am looping through a resultset within a transaction and I need to INSERT a unique datetime value within a table for each iteration through the resultset - will GetDate() be recalculated each time or will it only be calculated the first time and then be the same for each iteration through the loop?  </p>
  
  <p>My pseudo-code is below:</p>
  
  <pre><code>BEGIN TRANSACTION
  GO
  
  DECLARE @ID INT 
  DECLARE @table TABLE (/* Columns */) 
  
  WHILE (SELECT COUNT(*) FROM @table WHERE PROCESSED = 0) &gt; 0
        BEGIN
  
              SELECT TOP 1 @ID = ID FROM @table WHERE PROCESSED = 0 
  
              -- INSERT GetDate() into child table at this point. 
              -- Will GetDate() be re-evaluated each time? 
  
              UPDATE @table SET PROCESSED = 1 WHERE ID = @ID 
  
        END
  
  END TRANSACTION
  GO
  </code></pre>
  
  <p>Thanks in advance!</p>