如果旧值不等于新值,我希望我的触发器仅在更新时执行。如果值保持不变,我不希望我执行 if 块。
if UPDATE(interview)
BEGIN
EXEC sp_send_dbmail
@profile_name = 'SM_PRFL',
@recipients = 'email',
@subject = 'this is a test' ,
@body = 'message'
END
如果旧值不等于新值,我希望我的触发器仅在更新时执行。如果值保持不变,我不希望我执行 if 块。
if UPDATE(interview)
BEGIN
EXEC sp_send_dbmail
@profile_name = 'SM_PRFL',
@recipients = 'email',
@subject = 'this is a test' ,
@body = 'message'
END
查看以下链接,查找“在 INSTEAD OF 触发器中使用插入和删除的表”:http: //msdn.microsoft.com/en-us/library/ms191300 (SQL.90).aspx
这应该允许您执行测试并根据需要执行操作。例如,您可以...
If ( Update(interview))
BEGIN
-- If column esb has been changed from its previous value
IF ((SELECT esb FROM INSERTED) <> select esb FROM DELETED)
BEGIN
EXEC sp_send_dbmail
@profile_name = 'SM_PRFL',
@recipients = 'email',
@subject = 'this is a test' ,
@body = 'message'
END
END