Create Trigger CurrentEventTrigger On B
For Insert
AS
Begin
Insert into A
(
c1,
c2,
c3,
c4
)
Select
b1,
b2,
b3,
b4
from inserted --這樣
End
For Insert
AS
Begin
Insert into A
(
c1,
c2,
c3,
c4
)
Select
b1,
b2,
b3,
b4
from inserted --這樣
End
Create Trigger CurrentEventTrigger On B
For Insert
AS
if not exists(select 1 from A,inserted B where A.c1=B.b1 and A.c2=B.b2 and A.c3=B.b3 and A.c4=B.b4)
Begin
Insert into A
(
c1,
c2,
c3,
c4
)
Select
b1,
b2,
b3,
b4
from inserted
End
FOR INSERT
AS
BEGIN
INSERT INTO A (c1,c2,c3,c4)
SELECT b1,b2,b3,b4
FROM INSERTED
END