create
trigger
tri_update_tb_1_pk
on
tb_1
for
update
as
if
not
update(col_pk)
return
update
tb_2
set
col_pk=i.col_pk
from
tb_2,inserted
i,deleted
d
where
tb_2.col_pk=d.col_pk
and
i.Col_Uq=d.Col_Uq
go
如果保证每次只更新一行,那可以如下写触发器:
create
trigger
tri_update_tb_1_pk
on
tb_1
for
update
as
if
not
update(col_pk)
return
if
(select
count(*)
from
inserted)>
1
return
update
tb_2
set
col_pk=i.col_pk
from
tb_2,inserted
i,deleted
d
where
tb_2.col_pk=d.col_pk
go
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)