Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Auto update value when record gets updated

Author  Topic 

vermorel
Starting Member

26 Posts

Posted - 2006-02-21 : 04:04:15
I have a table that contains a field LastUpdated. This field should contains the date of the last update of the record.

Is there a way to auto-update this field value to the getdate() value each time the record is "touched" by an UPDATE sql command?

Thanks in advance,
Joannes

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2006-02-21 : 04:23:30
Look into the use of triggers...

Of course, if ALL updates happened via application, you could change your updates to:

Update ATable
Set AColumn = NewValue,
LastUpdated = GetDAte()

...

CiaO

*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!
Go to Top of Page
   

- Advertisement -