Hi all,
I have a simple need--I have a table into which data will be inserted. There are about 5 fields in this table that are not included in the insert statement (and can't be in the insert stmt for reasons to detailed to get into here).
So, I need a database level trigger in which I need to access data from other table(s) and update those fields. Of course I don't want a circular loop of this trigger so I don't want to do an actual Update to the table within this trigger (not sure if that's even possible). So is there a way I can do:
Thanks,
--Jim
I have a simple need--I have a table into which data will be inserted. There are about 5 fields in this table that are not included in the insert statement (and can't be in the insert stmt for reasons to detailed to get into here).
So, I need a database level trigger in which I need to access data from other table(s) and update those fields. Of course I don't want a circular loop of this trigger so I don't want to do an actual Update to the table within this trigger (not sure if that's even possible). So is there a way I can do:
Code:
Create Trigger For Insert..blah..blah
--Assuming this is not a bulk insert, i.e. one-record-per-insert stmt
Select @foo = foo,@bar=bar,@pepe=pepe FROM OtherTable WHERE OtherTable_ID = Inserted.OTID;
--wondering if the below will 'slipstream' the fields instead of triggering this same trigger on the actual table
Update Inserted Set foo=@foo,bar=@bar,pepe=@pepe;
--Jim