title: Most efficient way to calculate a hash or checksum for a row with many columns?
body: <p>I have a scenario where I need to check if rows in a target database need updating from a source database. The source data is actually a view and data from that view gets pumped into a destination table. Because the source view collects/rolls-up/pivots data from  several underlying tables we don't really have a good way to change the schema to support change tracking, so my thought was to compute a hash of each row's data and include that as part of the view. We can then compare the hash value in the destination table to see if there's a difference and update accordingly.</p>
  
  <p>I'm aware of the:</p>
  
  <pre><code>CHECKSUM
  BINARY_CHECKSUM
  HASHYBYTES
  </code></pre>
  
  <p>functions. Either CHECKSUM() or BINARY_CHECKSUM() seems to be the best option but I'm not sure how well it will perform over a view with 50 columns and a million+ rows. I'm also aware that the checksums/hashes generated may not be different even after an edit, but that's tolerable in this case.</p>
  
  <p>So the question: Is the hash/checksum approach a good way to do this and if so what's the best function to use? Or is there another, better way entirely to approach the problem?</p>
  
  <p>(Oh, running on SQL Server 2005 now but we'll soon be moving to 2008R2, if that helps.)</p>