469,608 Members | 2,153 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,608 developers. It's quick & easy.

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 4438
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 devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.