有表A(A_1,A_2) 表B(B_1,B_2)
假设update前A_1叫old_A_1,old_A_2
假设update后A_1叫new_A_1,new_A_2
if old_A_2 ='UP' then
UPdate B set B_2='UUUUU' where old_A_1=B_1; if old_A_2 ='DOWN' then
UPdate B set B_2='DDDDD' where old_A_1=B_1;
if new_A_2='UP' then
UPdate B set B_2='FFFF' where new_A_1=B_1; if new_A_2='DOWN' then
UPdate B set B_2='GGGG' where new_A_1=B_1;
假设update前A_1叫old_A_1,old_A_2
假设update后A_1叫new_A_1,new_A_2
if old_A_2 ='UP' then
UPdate B set B_2='UUUUU' where old_A_1=B_1; if old_A_2 ='DOWN' then
UPdate B set B_2='DDDDD' where old_A_1=B_1;
if new_A_2='UP' then
UPdate B set B_2='FFFF' where new_A_1=B_1; if new_A_2='DOWN' then
UPdate B set B_2='GGGG' where new_A_1=B_1;
UPdate B set B_2='GGGG' where new_A_1=B_1;
on a
for update
as
update b set b_2='UUUUU' where a_2='UP' and A_1=B_1
UPdate B set B_2='DDDDD' where A_2 ='DOWN' and old_A_1=B_1;
UPdate B set B_2='GGGG' from inserted i where i.A_2='DOWN' and i.A_1=B_1
after update
as
begin
update B set B.B_2=case when i.A_2='UP' then 'UUUUU'
when i.A_2='DOWN' then 'DDDDD'
when i.A_2='UP' and B.B_2='UUUUU' then 'FFFF'
when i.A_2='DOWN' and B.B_2='DDDDD' then 'GGGG'
end
from B,inserted i
where B.B_1=i.A_1
end
after update
as
begin
update B set B.B_2=case when A.A_2='UP' then 'UUUUU'
when A.A_2='DOWN' then 'DDDDD'
when A.A_2='UP' and B.B_2='UUUUU' then 'FFFF'
when A.A_2='DOWN' and B.B_2='DDDDD' then 'GGGG'
end
from B,A
where B.B_1=A.A_1
end