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.
| Author |
Topic |
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2005-09-20 : 13:28:21
|
| Can I write a trigger that fires like..when new rows(5) are inserted into a table,I want the IDENTITY values of this 5 rows to be inserted into its child table where it has the same column as FK.If its possbile to write a trigger,can any one help how to do tht? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-09-20 : 13:43:19
|
[code]create trigger trig_table1asinsert into table2 (columns)select columnsfrom table1 t1 join inserted i on t1.id = i.id[/code]Go with the flow & have fun! Else fight the flow |
 |
|
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2005-09-20 : 13:50:38
|
| Here is my requirementTableA (A1(PK),A2,A3)TableB (B1(PK),A1(FK),B2,B3)when 5 rows are inserted into TableA,I want to insert 5 A1 values into TableB(A1). |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-09-20 : 14:05:47
|
i gave you the conceptual solution.now you just need to apply it to your problem.or is there some other problem you're not telling us?Go with the flow & have fun! Else fight the flow |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-20 : 14:27:18
|
| CREATE TRIGGER itrg_Table1 ON Table1FOR INSERTASINSERT INTO Table2(A1)SELECT A1FROM insertedGOTara |
 |
|
|
|
|
|