title: Trigger to update lastModified column automatically in MSSQL server using scope_identity()
body: <p>I'm trying to create a trigger that automatically updates a column for an entry in my table when that specific entry is updated. </p>
  
  <p>The table name is "accounts". The column name is "modified" (it is a dateTime that states when this entry was last updated).</p>
  
  <p>I am using SCOPE_IDENTITY() to point to the entry which I wish to update.</p>
  
  <p>The trigger is created successfully, but when I update an entry, the column "modified" does not change. perhaps I'm using SCOPE_IDENTITY() incorrectly? Here is my code:</p>
  
  <pre><code>CREATE TRIGGER trg_UpdateModified
  ON dbo.accounts
  AFTER UPDATE
  AS
      UPDATE dbo.accounts
      SET modified = GETDATE()
      WHERE sysID = SCOPE_IDENTITY()
  </code></pre>
  
  <p>Thanks!!</p>