B boclif Unregistered / Unconfirmed GUEST, unregistred user! 2002-06-20 #1 有两个表A和B,其中有一些属性相同,我想写一个TRIGGER,在表A执行插入或修改时,表B相同的列 做相应的动作。应该如何写,请写出详细的过程,谢谢!!!
D dhl2001 Unregistered / Unconfirmed GUEST, unregistred user! 2002-06-20 #2 在a上建一个for update触发器, 修改b中的记录, 至于具体怎么定写 自已搞定吧 对你有好处的
完 完颜康 Unregistered / Unconfirmed GUEST, unregistred user! 2002-06-20 #3 CREATE TRIGGER trigger_name on tableA for insert as Insert into B(Id,Field) select ins.ID,ins.Field from inserted ins go 修改和它差不多,要的话再写
CREATE TRIGGER trigger_name on tableA for insert as Insert into B(Id,Field) select ins.ID,ins.Field from inserted ins go 修改和它差不多,要的话再写
U ugvanxk Unregistered / Unconfirmed GUEST, unregistred user! 2002-06-20 #4 create trigger aa on a for update as if update(name) update b set b.name=i.name from inserted i where a.id=i.id create trigger b_del on a for delete as declare @id char(10) select @id=id from deleted delete from b where id=@id create trigger ua on a for insert as insert into b (id,name) select i.id,i.name from inserted i
create trigger aa on a for update as if update(name) update b set b.name=i.name from inserted i where a.id=i.id create trigger b_del on a for delete as declare @id char(10) select @id=id from deleted delete from b where id=@id create trigger ua on a for insert as insert into b (id,name) select i.id,i.name from inserted i