title: update field that could be null in stored procedure
body: <p>I have a table that contains two columns which could be null.</p>
  
  <p>I want to build a stored procedure to edit that table. in the stored procedure I did this:</p>
  
  <pre><code>@ID INT,
      @newBuildingName NVARCHAR(250),
      @newLocation NVARCHAR(3000),
      @newImage VARBINARY(MAX) = NULL,
      @newNote NVARCHAR(3000) = NULL,
      @result BIT OUTPUT
  </code></pre>
  
  <p>Not I can't decide in this point if the user has entered values for <code>newImage</code> or <code>newNote</code> fields, so I can't say </p>
  
  <pre><code>UPDATE myTable SET image = @newImage, note = @newNote
  </code></pre>
  
  <p>because these two fields might already have values and in this way I would be deleting those vaules, </p>
  
  <p>what should I do?</p>
  
  <p><strong>What I thing is</strong>
  make an <code>if-else</code> statement and try if the first field is null so make my update without it and then if my second field is null then make my update statement without it and if neither of them is null then make a full update statement but I thing that this is a very teduis process. </p>
  
  <p>Is there any other solution plesae ?</p>
  
  <p>Thanks in advance </p>