I have been searching the net to see how to do this. I'm a noobie to DB's and I may have missed it. OK I have a Customer table and what I want to do is have a column with the date and time that the customer was added to the database ( i.e. Customer Since ) also last time that record was edited. Possible??
One option is to create a insert-trigger that sets a datetimestamp on inserting a new record. An update-trigger could do the update of a lastedit-field. See BOL (Books Online) for 'TRIGGER'. You can download the latest BOL from http://www.microsoft.com/downloads/d...DisplayLang=en
this could be a trigger to ensure the ClientStartDate is populated when one or more new rows are added
CREATE TRIGGER [trgClient_New]
set ClientStartDate = getdate()
from Clients, inserted
where inserted.ClientID = inserted.ClientID
This trigger will fire only when a row or rows are inserted. Inserted is a special table used by triggers and will be populated only when rows are inserted or updated (back to BOL to read more about these tables )