Keep Tracking Lastupdated Datetime In A TablePosted: September 8, 2010
First, you need to add a Lastupdated datetime column to your table and set the data type as datetime. After you created the column, you can assign a default value to the column with a GETDATE() function, which will insert a dattime when a new record is created. The last piece is to create a AFTER UPDATE trigger for the table.
Each time, when a record is being updated, the lastupdateddatetime will be updated accordingly.
Here is the sample code for the update trigger I created for a sample table:
CREATETRIGGER updatedatetimeChanged ON newTable AFTER UPDATE
BEGIN–newTable is the table name with a primary key field id
SET NOCOUNT ON;
FROM newTable n INNER JOIN deleted d ON n.id=d.id