1
我在一个表上创建一个触发器,它应该更新date_modified
列。下面的代码是最好的方法来做到这一点?我做对了吗?SQL Server 2008更新触发器 - 更新某些列方法
IF EXISTS(SELECT * FROM DELETED) --checking if this is an update, not insert
BEGIN
IF NOT(UPDATE(date_modified)) -- checking if desired column was not updated
BEGIN
DECLARE @updatedID int
SELECT @updatedID = ID FROM deleted -- fetching updated record ID
UPDATE table SET date_modified=GETDATE() WHERE [email protected] -- updating desired column
END
对不起,更新平台数据导入后和话题 – 2012-07-19 11:17:49
致谢!现在更清楚了! – 2012-07-19 11:39:41