title: SQL Insert trigger to update INSERTED table values
body: <p>I want to create an Insert trigger that updates values on all the inserted rows if they're null, the new values should be taken from a different table, according to another column in the inserted table.</p>
  
  <p>I tried:</p>
  
  <pre><code>UPDATE INSERTED
  SET TheColumnToBeUpdated = 
      (
      SELECT TheValueCol FROM AnotherTable.ValueCol
      WHERE AnotherTable.ValudCol1 = INSERTED.ValueCol1
      )
  WHERE ValueCol IS NULL
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>Msg 286, Level 16, State 1, Procedure ThisTable_INSERT, Line 15
  The logical tables INSERTED and DELETED cannot be updated.
  </code></pre>
  
  <p>How should I do that?</p>