At present I have a column with datatype datetime
with default constraint. Now I want to alter as a data type as time stamp.
alter table tblname
alter column date_modified timestamp not null
My original requirement is whenever I update a record the column called date_modified
should update with recent time .
This is same functionality which is working in MYSQL with datatype TIMESTAMP
and default value CURRENT_TIMESTAMP
How can I perform in this in SQL Server 2008??
Did you check what the TIMESTAMP type actually is in SQL Server? It's different from the TIMESTAMP type in mysql. The documentation says:
So there's no way to set it to "the current time"
Timestamp in MySQL and timestamp in SQL Server is not the same thing. Keep your
datetime
and add anafter update
trigger that updatesdate_modified
withgetdate()
.