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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Comparing field values in an Update Trigger

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-01 : 01:09:01
Frank writes "I want to set up a trigger that will fire when i update a field in one table and that field is = No. (all updates will be single row updates)

Example: if update(child) and (child = N) Execute trigger else don't execute the trigger. Do you know if this is possible and how i would code this. If both conditions are met i want to delete from another table. I believe this should involve comparing the old value from the DELETED table to the new value in the INSERTED table, but i'm not sure how to write this code. Here is as far as i could get. Unfortunately this fires on any and all updates.

CREATE TRIGGER [delete_product_child_onUpdate] ON [LOB]
FOR UPDATE
AS
IF UPDATE(child_i)

DELETE FROM PRODUCTS
WHERE lob_num IN (SELECT num FROM inserted)

Thanks
Frank"
   

- Advertisement -