triggers - Update last modified date column -
i have table this:
id name modified 11 john 2016-07-12 15:49:45 22 abraham 2016-07-12 15:52:03
i need update 'modified' column tracks last modified date row. have done using trigger, have read triggers eat performance. there way using constraints?
it's possible use default constraint , default keyword in update clause. see following example:
create table updatetest ( id int identity, name varchar(10), modified datetime2(2) constraint df_modified default (sysdatetime()) ) --id identity, modified default implicitly insert updatetest(name) values('test') --modified default explicitly update updatetest set name='test2', modified=default
Comments
Post a Comment