Home:ALL Converter>How to emulate MySQL's timestamp data type in SQL Server

How to emulate MySQL's timestamp data type in SQL Server

Ask Time:2014-09-29T23:41:18         Author:cja

Json Formatter

MySQL has a data type called timestamp. This is a date time field that is updated to now() when any data in the record is changed.

How can I achieve the same behaviour in SQL Server?

I know about the rowversion data type in SQL Server. I don't want this - I want an auto-updating date time value.

Author:cja,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26103710/how-to-emulate-mysqls-timestamp-data-type-in-sql-server
pmbAustin :

Create an INSTEAD OF INSERT trigger, in which you insert into your table, selecting all the columns from INSERTED except for the date time column you want to always reflect the current date time, and insert GETDATE() in for that column.\n\nThen create an INSTEAD OF UPDATE trigger, and do something similar, running an UPDATE statement against the table from inserted, using GETDATE() for that specific column.",
2014-09-29T16:38:34
yy