Triggers

MS-SQL 2000/5

I have an INSTEAD OF DELETE trigger which, rather than deleting a row, resets an IsValid flag in that row.

This process causes my BEFORE UPDATE trigger to be called (as it is doing an update). However, the BEFORE UPDATE trigger is giving error Msg 208, Invalid object name 'UPDATED' when I try an update the ModificationDate column.

Can somebody explain why? Alternatively, is there a way to prevent the INSTEAD OF DELETE trigger calling the BEFORE UPDATE trigger when it does the update of the InActive flag? At least then I can do all of the updates in the INSTEAD OF DELETE trigger.

INSTEAD OF DELETE

UPDATE
[dbo].[myTable]
SET
[dbo].[myTable].[IsValid] = 0
FROM
DELETED
WHERE
DELETED.[Id] = [dbo].[myTable].[Id];

BEFORE UPDATE

UPDATE
[dbo].[myTable]
SET
[dbo].[myTable].[ModifiedDate] = GETDATE()
FROM
UPDATED
WHERE
UPDATED.[Id] = [dbo].[myTable].[Id];

umm, I'm assuming my BEFORE UPDATE trigger is not calling itself (recursive)?
[1143 byte] By [rliq] at [2007-11-19 22:35:31]
# 1 Re: Triggers
Look what I found in a book: maybe it can help you:
"Trigger Execution
When a table insert or update fires a trigger, the trigger stores the new or modified
data in a table named Inserted. When a table delete fires a trigger, the trigger stores
the deleted data in a table named Deleted. The table exists in memory and is queried
within the trigger by using Transact-SQL commands. This capability is critical
to the function of most triggers because the task within the trigger, such as modifying
a value in an associated table, compares the data contained in the Inserted or
Deleted tables to the data in the modified table before the changes are committed.
By using the information stored in the Inserted or Deleted table, a trigger can roll
back a transaction to enforce business rules."
DanielaTm at 2007-11-9 13:43:45 >