Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Populating multiple rows from a Trigger

Author  Topic 

sujosh
Yak Posting Veteran

55 Posts

Posted - 2006-02-09 : 15:49:02
There are tables A,B and C. I want to write an insert trigger on table A that does go to table B and get all the rows and populate into table C.

How should I go about this?

Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2006-02-09 : 15:51:19
You shouldn't. Every time a row is insert to a, this action will always occur.

Can you explain what you are actually trying to do, not from a technical perspective?

Thanks

Read the hint link in my sig for some suggestions on how to pose your question



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

sujosh
Yak Posting Veteran

55 Posts

Posted - 2006-02-09 : 16:18:26
"Every time a row is insert to a, this action will always occur."
Yes that is exactly what I want it to happen. Here is why

When there is a new emp I want the default actions (that are stored in table B which is populated by admin tool) to be inserted into table C

Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-09 : 21:23:10
Something like this :
CREATE TRIGGER ti_tableA
ON tableA
FOR INSERT
AS
BEGIN
insert into tableC(colc1, colc2, colc3)
select i.col1, b.cola, b.colb
from inserted i inner join tableB b
on i.somecol = b.somecol
END


----------------------------------
'KH'

everything that has a beginning has an end
Go to Top of Page
   

- Advertisement -