检测插入/更新是否来自另一个触发器?
我有 table1 正在通过 sp's 更新和插入数据。
更新是根据行的 ID 进行的(不是批量更新) - 我的意思是 - 单次更新
。
该表有触发器Tg1 - 它更新已更新的同一记录中的某些字段。 (在数据库中更新记录后 - TG1 更新了她的一些字段)
I DONT HAVE ACCESS to TG1 !.
此表有另一个触发器,我构建了 Tg2。 通过 SELECT * FROM DELETED ... 归档原始插入记录并插入到表 Archive...
问题是 Tg2 也捕获 TG1 的活动! (它将 3 条记录插入到存档表 1 中。
问题:是否有(在 TG2 中)知道该操作来自 Tg1 ?(所以我会能够避免这些事件 - 因为我只需要来自我的 sp 的事件。)
我该如何解决这个问题?(我无权访问 tg1...)
I have table1 which is being updated and inserted with data via sp's.
the update is per Id of the row ( not bulk update) - I mean - Single update
.
This table has Trigger Tg1 - which updates some fields in the same record that has been updated . ( after the record updated in the db - TG1 update some of her fields)
I DONT HAVE ACCESS to TG1 !.
This table has another trigger which ive build Tg2.
which archive the original inserted record via SELECT * FROM DELETED ... and insert to table Archive...
the problem is that Tg2 catches also
the events for TG1 ! ( it inserting to the archive table 3 records insted of 1.
Question : Is there anyway (in TG2) to know that the Action came from Tg1 ? ( so i would be able to avoid those events - since i need only the events which came from my sp.)
How can i solve that ? ( i dont have access to tg1...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么您不想归档最终存在于表中的记录?
但是,您可以使用以下命令将触发器上的触发顺序设置为第一个
sp_settriggerorder。在在线书籍中查找如何做到这一点。
Why would you not want to archive the record as it finally exists in the table?
However, you can set the trigger order on your trigger to be the first one using
sp_settriggerorder. Lookup in Books online how to do that.