title: SQL Query to update a column based on the values of other columns in the same table
body: <p>Ok this is difficult to phrase, so here goes...</p>
  
  <p>I am using MS SQL Server 2008 R2. I have a temp table that lets say has two already populated columns. There is a third empty column I want to populate based on the value of the first two columns. What I want to do is create a guid (using NEWUID()) for each matching combo of col1 and col2. Here is a visual example:</p>
  
  <p>Lets say I have a temp table that looks like this initially:</p>
  
  <pre><code>Name    Activity    SpecialId
  James   Running     
  James   Running
  James   Walking
  John    Running
  John    Running
  John    Walking
  </code></pre>
  
  <p>I want it to get updated with new GUIDs so that it looks like this:</p>
  
  <pre><code>Name    Activity    SpecialId
  James   Running     SOMEFAKEGUID_1
  James   Running     SOMEFAKEGUID_1
  James   Walking     SOMEFAKEGUID_2
  John    Running     SOMEFAKEGUID_3
  John    Running     SOMEFAKEGUID_3
  John    Walking     SOMEFAKEGUID_4
  </code></pre>
  
  <p>Notice how a new GUID is created for each matching pair. So the James/Running combo has the same GUID for all James/Running combos... and the John/Running also has the same GUID for the John/Running combos, but not the same GUID as the James/Running combos do.</p>
  
  <p>I tried to make that as clear as possible, but hopefully that isn't clear as mud!</p>
  
  <p>Can someone show me what the SQL query would look like in order to update that temp table with the correct GUIDs?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Ryan</p>