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 |
|
loppis99
Starting Member
6 Posts |
Posted - 2007-11-03 : 09:18:59
|
| Hi, I'm new at triggers and needs some help.I have two tables, and on update in table_1, i want to insert the row in table_2That works fine with one row, but if the update have two rows only one will be inserted in table_2Help me please!!!!! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-03 : 09:22:46
|
because your insert trigger did not handle set operations. sample insert into table_2( <col list> )select <col list>from inserted Read these article on triggers http://www.sqlteam.com/tag/sql-server-triggers KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
loppis99
Starting Member
6 Posts |
Posted - 2007-11-03 : 10:09:01
|
| Thanks, another question:How can i set the column "Status" to 1 in table_2, in this triggerThat column does mot exist in table_1Thanks again |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-03 : 10:11:33
|
[code]insert into table_2( <col list>, status )select <col list>, 1from inserted[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
loppis99
Starting Member
6 Posts |
Posted - 2007-11-03 : 10:20:23
|
| Nice, Thanks a lot |
 |
|
|
|
|
|