question

GPO avatar image
GPO asked

Automatically set the modified date on a row that changes

(SQL Server 2005 or later) What's the best way to make sure that when a row is inserted or updated, the [modified_date] column will always be updated with the current datetime? I ask because as a general principal, those in the know seem to be lukewarm on the use of triggers. In this case though, I can't think of a more reliable way of achieving the stated outcome. Are there any traps for new players when setting up this kind of trigger? Given that modified_date and modified_by seem to be fairly standard row metadata fields on transactional tables are there any "best practises"?
updateinserttriggermetadata
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
GPO avatar image
GPO answered
I've just seen this: http://ask.sqlservercentral.com/questions/114414/record-value-change-tracking.html I do apologise for not looking a bit harder.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.