sqlserver创建触发器 当我把一个表中数据更改时另一个表中的数据也改变,两张表的字段不相同

有class表和product表 当class表中的cid字段修改时,product表中的pcid数据自动更新成与cid一样的值

第1个回答  2018-05-31
--创建多表更新触发器(trg_class_Update)
create Trigger [dbo].[trg_class_Update]
On [dbo].[class]
after update
As
if update(cid) --变更cid时触发
begin
update product set pcid=I.cid from product as B,deleted D, inserted as I where B.pcid=D.cid
end
go本回答被提问者和网友采纳
相似回答