日期:2014-05-19  浏览次数:20437 次

insert 操作是否会触发关于update的触发器?
定义一个触发器,如果某列被更新,同时去更新另一张表的相同列。insert   操作会触发吗?
另外,我这张表上insert纪录非常频繁,每秒大概会Insert   50条左右的纪录。update操作相对较少。

------解决方案--------------------
create trigger tu_表 on 表
for update
as
if update(列)
begin
...
end
------解决方案--------------------
不会
------解决方案--------------------
看你的代碼寫的有沒有問題了,如果你控制的是正確的話,insert 操作是不会触发关于update的触发器的。
------解决方案--------------------
单独写update触发器,insert不会受影响
另外,if update(列)可以指定列被更新才触发update触发器
------解决方案--------------------
insert不会触发更新,请创建update触发器
------解决方案--------------------
create trigger tu_表 on 表
for update
as
if update(列) and exists(select 1 from inserted i,deleted d where i.id=d.id and isnull(i.列, ' ') <> isnull(d.列, ' ')) --被更新的行.i.id=d.id为实际你表的主键
begin
...
end

------解决方案--------------------
我需要的是定义到被更新的这一行,然后要去匹配另一张表的相同的行。
----------------------------------------
那个判断就是检查指定列的哪些行被更新了啊,匹配的代码在省略号处写.还有什么不明白的吗?
------解决方案--------------------
只要没写错,是不会的!