两张表主表:drug_info,从表: cpa_drug。其中主表的pzwh和从表的batch_no字段相关联。主表的pzwh字段改变的时候从表中的bathc_no字段也要改变,并且当主表xh_code的字段改变的时候从表中frug_no的字段也要改变,保留没有改变的数据!怎么写触发器啊?我写了个存储过程,不过,查询速度无法令我满意!查了十多分钟都没查出来!各位救救我吧!
create procedure pro_gxcd
as
update testcpa_drug
set testcpa_drug.drug_code=testdrug_info.xh_code
from testdrug_info
where testdrug_info.pzwh=testcpa_drug.standard_id
go