The first option may be more reliable, since the database will support this field. This is due to the potential costs of using triggers.
If you could write other applications to this table in the future using your own interfaces, I would go with a trigger so that you don't repeat this logic anywhere else.
If your application, to a large extent, it or some other applications will access the database through the same data file, I would avoid this nightmare, which triggers can trigger and put logic directly into your datalayer (SQL, ORM, stored procs , etc.).
Of course, you have to make sure that your source of time (your application, your users, your SQL server) is accurate anyway.
Regarding why I don't like triggers:
Perhaps I had a rash, calling them a nightmare. Like everything else, they fit in moderately. If you use them for very simple things like this, I can get on board.
This is when trigger code becomes complex (and expensive) that triggers a lot of problems. This is a hidden tax on each insert / update / delete request you make (depending on the type of trigger). If this tax is acceptable, they may be the right tool for the job.
Michael haren
source share