更新时自动停用旧记录的触发器
我正在刷新记录。我需要创建一个触发器来自动停用旧记录。记录被更新到一个不一样的新表中。新插入记录和原始记录之间的值由 2 列匹配,假设 col1 和 col2
ALTER TRIGGER TR_On_Renewed_Customer
ON CustomerTable2
FOR INSERT
AS
// psudeo code
// Deactive the old record in customertable1
// if match is found between CustomerTable2 and
// CustomerTable1 based on col1 and col2, then update Active ='No'
我有点迷失如何在此查询中使用 EXIST。
I am renewing a record. I need to create a trigger that will automatically deactivate the old record. Records are renewed into a new table not the same. Values between the newly insert record and original record are match by 2 columns, let's say col1 and col2
ALTER TRIGGER TR_On_Renewed_Customer
ON CustomerTable2
FOR INSERT
AS
// psudeo code
// Deactive the old record in customertable1
// if match is found between CustomerTable2 and
// CustomerTable1 based on col1 and col2, then update Active ='No'
I am a little bit lost how to use EXIST in this query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关键是使用特殊的
Inserted
表,其中包含刚刚受到导致触发器触发的INSERT
操作影响的行。The key is to use the special
Inserted
table, which contains the rows that were just impacted by theINSERT
operation that caused the trigger to fire.