Positonic
Positonic

Reputation: 9411

Save when a record was updated last in SQL Server

I need to track when a tables records are updated.

I am thinking I'd like to add a column that saves a time stamp, that way I can select records who's timestamp is greater than my last update time stamp.

I have done some research on the subject here and the web and I'm a bit confused by the whole timestamp thing. So I am thinking that I will just create

On MSDN

A future release of Microsoft® SQL Server™ may modify the behavior of the Transact-SQL timestamp data type to align it with the behavior defined in the standard. At that time, the current timestamp data type will be replaced with a rowversion data type.

So my current thinking is that I just create a new column on the table of type datetime and update that whenever I insert of update a record.

A built-in timestamp on the table would save be a bit of work though, so that's why I ask.

Upvotes: 2

Views: 272

Answers (1)

lowds
lowds

Reputation: 1135

Add a DateTime column to the table and then update this column using a trigger that is executed on Insert or Update

Upvotes: 8

Related Questions