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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-08-06 : 13:39:01
|
| how can I code in the trigger that it should insert into another table the identity field of the table that i'm making the trigger on CREATE TRIGGER insertinfo ON [dbo].[order_details] FOR INSERTASinsert into information(order_item_id,mfg_status) values(@@identiry,'nothing')" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-08-06 : 13:46:42
|
CREATE TRIGGER insertinfo ON [dbo].[order_details] FOR INSERTASinsert into information(order_item_id,mfg_status) select pkCOl, 'nothing' from inserted N 56°04'39.26"E 12°55'05.63" |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-08-06 : 14:21:14
|
| thanks :) |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-08-09 : 05:27:26
|
| How can I have the trigger above first count if any records exits with that order_item_id and only add if no record exists? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-09 : 05:50:18
|
insert into information(order_item_id,mfg_status) select DISTINCT pkCOl, 'nothing' from insertedwhere not exists(select * from information where order_item_id=inserted.pkCOl) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-09-16 : 15:27:23
|
| tried to use this somewhere else what am i doing wrong alter TRIGGER insertex ON [dbo].[transcations]FOR INSERTASdeclare @transactionid intselect @transactionid=id from insertedexec spinsertex @transactionidI get an error Invalid object name 'inserted' |
 |
|
|
|
|
|