title: SQL Server syntax to replace existing values in a table by new ones
body: <p>I am using SQL Server 2014 and I have a table called ReservationStay with 2 columns, namely ResaID and TAProfileID.<br>
  The ReservationStay table contains more than 50,000 records. I need to change the some values of the TAProfileID. I have identified all the ResaID where a change of the TAProfileID is needed and I have around 4,000 records to change.</p>
  
  <p>I could write my SQL query as below:</p>
  
  <pre><code>UPDATE ReservationStay
  SET TAProfileID = CASE Resaid
  WHEN  119 THEN 984
  WHEN  155 THEN 984
  WHEN  175 THEN 255
  .................
  ELSE TAProfileID
  END
  GO
  </code></pre>
  
  <p>and so on.</p>
  
  <p>However I will need to create the query for 4,000 records!</p>
  
  <p>On the other hand, I have also noticed that only 22 TAProfileID needs to be changed! It's just that these 22 TAProfileID are all together connected to more that 4,000 Resaid. Instead of changing the TAProfileID based on Resaid, I would like to rather correct the TAProfileID based on the 'OLD' TAProfileID. This would be easier to maintain.</p>
  
  <p>In other words, my SQL query should take this logic into consideration:</p>
  
  <p>IF TAProfileID = 564 THEN TAProfileId becomes 984</p>
  
  <p>IF TAProfileID = 701 THEN TAProfileID becomes 255</p>
  
  <p>How do I write my query to handle this?</p>