I would like to have a date_last_modified field for one of my SQL
tables. Instead of coding my front end to keep up with this field is
there a way to user a formula for this column in Enterprise Manager so
that each time a record is created or updated the current date/time
will be inserted/updated? I tried using getdate() but then the field
always has the current time, which is not what I am looking for. I am
looking for the time the row is updated or created. Is this possible?
Thank you!For insert new record, set the default value to getdate().
For update on an existing row. A trigger will do that. The trigger work
for insert too.|||BUT the method I preferred is using stored procedure rather than a
trigger. trigger is unforgiving. In the case you want to manually fix
some data in the database, the trigger is always triggeed.
The client app invoke the stored procedure with all the parameters
except date_last_modified. The SP fills the date_last_modified with
GETDATE().
JOHN
No comments:
Post a Comment