单行跟新可用
create trigger tr_a on b
for update
begin
declare @newno char(20)
declare @oldno char(20)
if update(us_no)
select @newno=inserted.us_no from inserted
select @oldno=deleted.us_no from deleted
update a set us_no=@newno where us_no=@oldno
end
多行时a应该有除了us_no外还有唯一键id标志行
create trigger tr_a on b
for update
begin
if update(us_no)
update a set a.us_no=inserted.us_no from inserted,deleted
where a.us_no=deleted.us_no and deleted.id=inserted.id
end
create trigger tr_a on b
for update
begin
declare @newno char(20)
declare @oldno char(20)
if update(us_no)
select @newno=inserted.us_no from inserted
select @oldno=deleted.us_no from deleted
update a set us_no=@newno where us_no=@oldno
end
多行时a应该有除了us_no外还有唯一键id标志行
create trigger tr_a on b
for update
begin
if update(us_no)
update a set a.us_no=inserted.us_no from inserted,deleted
where a.us_no=deleted.us_no and deleted.id=inserted.id
end
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货