Question About DateCreated and DateModified Columns - SQL Server
Posted
by user311509
on Stack Overflow
See other posts from Stack Overflow
or by user311509
Published on 2010-04-09T19:39:44Z
Indexed on
2010/04/09
20:13 UTC
Read the original article
Hit count: 310
CREATE TABLE Customer
(
customerID int identity (500,20) CONSTRAINT
.
.
dateCreated datetime DEFAULT GetDate() NOT NULL,
dateModified datetime DEFAULT GetDate() NOT NULL
);
When i insert a record, dateCreated and dateModified gets set to default date/time. When i update/modify the record, dateModified and dateCreated remains as is? What should i do?
Obviously, i need to dateCreated value to remain as was inserted the first time and dateModified keeps changing when a change/modification occurs in the record fields.
In other words, can you please write a sample quick trigger? I don't know much yet...
© Stack Overflow or respective owner