471,889 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,889 software developers and data experts.

Using Trigger to populate another table

Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....
Jul 20 '05 #1
2 4498
Try

Create trigger tbl_AIns on tbl_A
for Insert as
begin
INSERT tbl_B
Select field_1
, field_2
from INSERTED
End

HTH,
Srinivas Sampangi
"June Moore" <ju******@yahoo.com.au> wrote in message
news:e5**************************@posting.google.c om...
Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....

Jul 20 '05 #2
Hello June !

Try this

The statement in the trigger is:

Insert into table2
Select field_1,field_2 from inserted

Jens Süßmeyer.

"June Moore" <ju******@yahoo.com.au> schrieb im Newsbeitrag
news:e5**************************@posting.google.c om...
Hi all,
I have two tables tbl_A and tbl_B.
Table Definitions:
tbl_A (field_1, field_2, field_3)
tbl_B (field_1, field_2)
I would like to populate tbl_B when a record is inserted into tbl_A.
Note that tbl_A.field_1 = tbl_B.field_1 and tbl_A.field_2 =
tbl_B.field_2 .

How do I write a trigger on tbl_A to get the corresponding record
inserted into tbl_B?

Regards
June.....

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Sjaak van Esdonk | last post: by
2 posts views Thread by gustavo_randich | last post: by
2 posts views Thread by mike | last post: by
7 posts views Thread by Serge Rielau | last post: by
3 posts views Thread by lenygold via DBMonster.com | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.