MickeD
Programmer
- Feb 20, 2000
- 54
Hi,
I need to create insert/update trigger that checks some value in another table and put the result in one of the fields in the updated table (after insert/update process)
Here is a code i try:
CREATE TRIGGER TR_Check_IF_Arrived ON tbl_Test
FOR INSERT, UPDATE
AS
declare @stat char(2)
select @stat=m.status_cd
from tbl_Main m, inserted i
where s.rec_id=i.ship_id
if @stat in ('02','03','04','05')
update inserted set IsArrived=1
GO
the error i get says:
"The logical tables INSERTED and DELETED cannot be updated."
I can update the table (tbl_test) directly, i need overwrite the value in the field IsArrived in inserted
So how can i do it?
I need to create insert/update trigger that checks some value in another table and put the result in one of the fields in the updated table (after insert/update process)
Here is a code i try:
CREATE TRIGGER TR_Check_IF_Arrived ON tbl_Test
FOR INSERT, UPDATE
AS
declare @stat char(2)
select @stat=m.status_cd
from tbl_Main m, inserted i
where s.rec_id=i.ship_id
if @stat in ('02','03','04','05')
update inserted set IsArrived=1
GO
the error i get says:
"The logical tables INSERTED and DELETED cannot be updated."
I can update the table (tbl_test) directly, i need overwrite the value in the field IsArrived in inserted
So how can i do it?