求一触发器。
表A中有下字段
ID int
Entry char(20)
表B中有下字段
ID int
Entry char(20)
要求对表A操做时同时对表B操做
Create trigger tri_A on B
after insert,update,delete
。。。。。。。。。
------解决方案--------------------http://blog.csdn.net/Haiwer/archive/2007/07/30/1717206.aspx
------解决方案--------------------Create trigger tri_A on B
after insert,update,delete
As
Begin
--插入
If Exists(Select 1 From Inserted) And Not Exists(Select 1 From Deleted)
Insert A Select * From Inserted
--更新
If Exists(Select 1 From Inserted) And Exists(Select 1 From Deleted)
Update A Set Entry = B.Entry From A Inner Join Inserted B On A.ID = B.ID
--刪除
If Not Exists(Select 1 From Inserted) And Exists(Select 1 From Deleted)
Delete A From A Inner Join Deleted B On A.ID = B.ID
End