title: After insert, update timestamp trigger with two column primary key
body: <p>I have a simple details table like so:</p>
  
  <pre><code>listid
  custid
  status
  last_changed
  </code></pre>
  
  <p>The primary key consists of both <code>listid</code> and <code>custid</code>.</p>
  
  <p>Now I'm trying to setup a trigger that sets the <code>last_changed</code> column to the current datetime every time an insert or update happens. I've found lots of info on how to do that with a single PK column, but with multiple PKs it gets confusing on how to correctly specify the PKs from the INSERTED table.</p>
  
  <p>The trigger has to work in SQL Server 2005/2008/R2.</p>
  
  <p>Thanks for a working trigger code!</p>
  
  <p>Bonus would be to also check if the data was actually altered and only update last_changed in that case but for the sake of actually understanding how to correctly code the main question I'd like to see this as a separate code block if at all.</p>