title: SQL Server & update (or insert) parallelism
body: <p>I got a large conversion job- 299Gb of JPEG images, already in the database, into thumbnail equivalents for reporting and bandwidth purposes.</p>
  
  <p>I've written a thread safe SQLCLR function to do the business of re-sampling the images, lovely job. </p>
  
  <p>Problem is, when I execute it in an <code>UPDATE</code> statement (from the PhotoData field to the ThumbData field), this executes linearly to prevent race conditions, using only one processor to resample the images. </p>
  
  <p>So, how would I best utilise the 12 cores and phat raid setup this database machine has? Is it to use a subquery in the <code>FROM</code> clause of the update statement? Is this all that is required to enable parallelism on this kind of operation?</p>
  
  <p>Anyway the operation is split into batches, around 4000 images per batch (in a windowed query of about 391k images), this machine has plenty of resources to burn. </p>