Groups | Blog | Home
all groups > sql server (alternate) > august 2003 >

sql server (alternate) : Using Trigger to populate another table


jungewum NO[at]SPAM yahoo.com.au
8/20/2003 9:51:51 PM
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
sampangi
8/20/2003 10:01:21 PM
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


[quoted text, click to view]

Jens Süßmeyer
8/21/2003 7:03:05 AM
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" <jungewum@yahoo.com.au> schrieb im Newsbeitrag
news:e5dfaf21.0308202051.283c382f@posting.google.com...
[quoted text, click to view]

AddThis Social Bookmark Button