create trigger trg_adddata on A
after insert
as
begin
update A
set A.诊断 = B.诊断名称
from A inner join B where A.诊断编码= B.诊断编码
where not exists(select 1 from B where A.诊断 = B.诊断名称)
end--参考,这个实际上在前台做处理更好。
after insert
as
begin
update A
set A.诊断 = B.诊断名称
from A inner join B where A.诊断编码= B.诊断编码
where not exists(select 1 from B where A.诊断 = B.诊断名称)
end--参考,这个实际上在前台做处理更好。
after insert
as
update A
set a.诊断=b.诊断名 from b where exists(select 1 from inserted i where a.编码=i.编码)
for insert
as
begin
declare @bh nvarchar(50)
select @bh=诊断编码 from inserted
update A set A.诊断 = B.诊断名称
from A inner join B on A.诊断编码= B.诊断编码 and B.诊断编码=@bh
end
各位大神不好意思,我好像表达错了,反而这个大大能了解我的意思,A表只有诊断,B表有诊断名称跟诊断编码,A表一开始的诊断插的是编码后面想改名称 ,就是这个意思 非常感谢啦
create trigger a_ins on A
for insert
as
begin
declare @bh nvarchar(50)
select @bh=诊断 from inserted
update A set A.诊断 = B.诊断名称
from A inner join B on A.诊断= B.诊断编码 and B.诊断编码=@bh
end