title: tsql bulk update
body: <p>MyTableA has several million records. On regular occasions every row in MyTableA needs to be updated with values from TheirTableA. </p>
  
  <p>Unfortunately I have no control over TheirTableA and there is no field to indicate if anything in TheirTableA has changed so I either just update everything or I update based on comparing every field which could be different (not really feasible as this is a long and wide table).</p>
  
  <p>Unfortunately the transaction log is ballooning doing a straight update so I wanted to chunk it by using UPDATE TOP, however, as I understand it I need some field to determine if the records in MyTableA have been updated yet or not otherwise I'll end up in an infinite loop:</p>
  
  <pre><code>declare @again as bit;
  set @again = 1;
  
  while @again = 1
    begin
      update top (10000) MyTableA
      set my.A1 = their.A1, my.A2 = their.A2, my.A3 = their.A3
      from MyTableA my
      join TheirTableA their on my.Id = their.Id
  
      if @@ROWCOUNT &gt; 0
        set @again = 1
      else
        set @again = 0
  end
  </code></pre>
  
  <p>is the only way this will work if I add in a </p>
  
  <pre><code>where my.A1 &lt;&gt; their.A1 and my.A2 &lt;&gt; their.A2 and my.A3 &lt;&gt; their.A3
  </code></pre>
  
  <p>this seems like it will be horribly inefficient with many columns to compare</p>
  
  <p>I'm sure I'm missing an obvious alternative?</p>