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.
| Author |
Topic |
|
jdoering
Starting Member
32 Posts |
Posted - 2002-09-25 : 10:15:18
|
| This is an easy question....I just can't remember how to do this...I have a table with 10 columns. Whenever 1 of these records in the table gets updated, I would like to update the corresponding column 'LastModified' (datetime data type) for that record with the time that this particular record was last updated. How do I do this?Thanks, |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-09-25 : 10:17:38
|
| Use an UPDATE trigger:CREATE TRIGGER SetLastModified ON myTable FOR UPDATE ASUPDATE MSET LastUpdated=GetDate()FROM myTable M INNER JOIN inserted I ON M.ID=I.IDThe ID column represents your primary key column(s), change it to match your actual table structure. If you don't have a primary key on the table, this trigger won't work. |
 |
|
|
jdoering
Starting Member
32 Posts |
Posted - 2002-09-25 : 10:19:55
|
| Thanks! |
 |
|
|
|
|
|