Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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?ThanksRead the hint link in my sig for some suggestions on how to pose your questionBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam
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 whyWhen 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 CThanks
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-02-09 : 21:23:10
Something like this :
CREATE TRIGGER ti_tableAON tableAFOR INSERTAS 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.somecolEND
----------------------------------'KH'everything that has a beginning has an end