create table pic
(
product_id varchar(20) references product(id) on update cascade on delete cascade,
pic varchar(20)
)
(
product_id varchar(20) references product(id) on update cascade on delete cascade,
pic varchar(20)
)
FROM sysobjects
WHERE name = N'<TR_PROD>'
AND type = 'TR')
DROP TRIGGER TR_PROD
GOCREATE TRIGGER TR_PROD
ON PRODUCT
FOR UPDATE
AS
If UPDATE(ID)
BEGIN
UPDATE PIC SET PRODUCT_ID=A.ID FROM DELETED A WHERE ....
END
GO
on product
for update
as
update pic set product_id=(select id from inserted) where product_id=(select id from deleted )
测试数据:update product set id=5 where id=1