I have a simple data table, for example:
listid custid status last_changed
The primary key consists of listid and custid .
Now I'm trying to set up a trigger that sets the last_changed column at the current time and time with every insert or update. I found a lot of information on how to do this with a single PK column, but with multiple PKs it gets confusing how to correctly specify PK from an INSERTED table.
The trigger should work in SQL Server 2005/2008 / R2.
Thanks for the working launch code!
The bonus will also check whether the data has really been changed and updated only in the latter case, but in order to really understand how to correctly code the main question, which I would like to see as a separate block of code, if for all.
source share