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 |
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-23 : 01:34:35
|
| Hi,Can a trigger get a constant from the outside?If I insert/update a table and whenever there is a value of "XX" (in a certain field)in the source table, i need it to be replaced in the destination table with a value according to the user application.I don't want the new value to be set in the trigger.ThanksYossi |
|
|
rihardh
Constraint Violating Yak Guru
307 Posts |
Posted - 2002-12-23 : 02:21:37
|
| You should consider using the INSERTED & DELETED tables for picking values... |
 |
|
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-23 : 02:38:13
|
quote: You should consider using the INSERTED & DELETED tables for picking values...
CAn you elaborate on that a bit... |
 |
|
|
rihardh
Constraint Violating Yak Guru
307 Posts |
Posted - 2002-12-23 : 03:49:56
|
| The INSERTED and DELETED tables are the only source in triggers for "dynamical" data. You use the deleted table for your "XX" value and the inserted table for your "application" value.The rest is in BOL... |
 |
|
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-23 : 04:38:41
|
quote: The INSERTED and DELETED tables are the only source in triggers for "dynamical" data. You use the deleted table for your "XX" value and the inserted table for your "application" value.The rest is in BOL...
Maybe i was not clear enough.If the trigger get the value "XX" it should change it to value that is specified else where, not in the trigger itself.Can i retrieve this constand some how from else where?Thanks |
 |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2002-12-23 : 09:52:57
|
| You could set up a lookup table of values that you want replaced. Take a look at the data in the column in the inserted table and look it up on your cross reference table to see if it needs to be replaced, then switch the values either after the insert or before, depending on the type of trigger you are using. |
 |
|
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-24 : 01:35:24
|
quote: You could set up a lookup table of values that you want replaced. Take a look at the data in the column in the inserted table and look it up on your cross reference table to see if it needs to be replaced, then switch the values either after the insert or before, depending on the type of trigger you are using.
Great...Thanks, I'll do that. |
 |
|
|
|
|
|