title: SQL Query - Increase int variable value by 1 each time it's used
body: <p>I am trying to update info of all records of a column in a table:</p>
  
  <pre><code>declare @FromDate date = '1950-01-01'     
  declare @ToDate date = '2002-12-31'   
  declare @Numb int = 14814    
  Update Users   
  Set BirthDate = dateadd(day,rand(checksum(newid()))*(1+datediff(day, @FromDate, @ToDate)), @FromDate)     
  WHERE UserID = @Numb
  </code></pre>
  
  <p>Could I somehow make the @Numb variable increase by 1 each time this is ran, or do I have to go about this in some other way?</p>
  
  <p>EDIT: Solved it with transactions</p>
  
  <pre><code>declare @FromDate1 date = '1950-01-01'
  declare @ToDate1 date = '2002-12-31'
  declare @Numb int
  begin transaction
  set @Numb = 14814
  while @Numb &lt; 16809
  begin
  exec usp_Update_Users @FromDate1, @ToDate1, @Numb
  set @Numb = @Numb + 1
  end
  commit transaction
  </code></pre>
  
  <p>Turned the above stuff into a stored procedure first of course. Thanks for the help everyone</p>