目前我们正在使用两个DateTime字段审核一个表:
[Creation] [datetime] NOT NULL DEFAULT (getutcdate()),
[Modification] [datetime] NOT NULL DEFAULT (getutcdate())
然后在UPDATE上有一个Trigger,用于更改[Modification]的值,如下所示:
CREATE TRIGGER [dbo].[Record_Updated]
ON [dbo].[MyTable]
FOR UPDATE /* Fire this trigger when a row UPDATE */
AS BEGIN
UPDATE [dbo].[MyTable]
SET [dbo].[Table].[Modification] = GETUTCDATE()
FROM [dbo].[MyTable]
JOIN INSERTED ON INSERTED.MyID = [dbo].[MyTable].[MyID]
END
问题是,因为我们正在处理客户数据库并且他们不想要TRIGGERS,在T-SQL中是否还有其他方法可以实现相同的结果? 数据库是> = SQL 2012或SQL Azure