title: SQL: How can I update a value on a column only if that value is null?
body: <p>I have an SQL question which may be basic to some but is confusing me.   </p>
  
  <p>Here is an example of column names for a table 'Person':
  PersonalID, FirstName, LastName, Car, HairColour, FavDrink, FavFood</p>
  
  <p>Let's say that I input the row:  </p>
  
  <blockquote>
    <p>121312, Rayna, Pieterson, BMW123d, Brown, NULL, NULL</p>
  </blockquote>
  
  <p>Now I want to update the values for this person, but only if the new value is not null, Update:  </p>
  
  <blockquote>
    <p>121312, Rayna, Pieterson, NULL, Blonde, Fanta, NULL</p>
  </blockquote>
  
  <p>The new row needs to be:  </p>
  
  <blockquote>
    <p>121312, Rayna, Pieterson, BMW123d, Blonde, Fanta, NULL</p>
  </blockquote>
  
  <p>So I was thinking something along the lines of:</p>
  
  <blockquote>
    <p>Update Person(PersonalID, FirstName, LastName, Car, HairColour,
    FavDrink, FavFood) set Car = @Car (where @Car is not null), HairColour
    = @HairColour (where @HairColour...)... etc.</p>
  </blockquote>
  
  <p>My only concern is that I can't group all the conditions at the end of the query because it will require all the values to have the same condition. Can't i do something like Update HairColour if @HairColour is not Null</p>