Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Delete Trigger then Update

Status
Not open for further replies.

Tinkerers

Technical User
Sep 26, 2002
90
US
Hi,

I've done a bunch of research and am striking out here. I need to create a Delete Trigger. When the user deletes 1 or more rows in Table_A, I need to perform an Update operation on Table_B. But I need to retrieve the AutoNumber field from Table_A and do the Update on Table_B Where AutoNumber is the same. I have tried this, but it seems to update ALL records in Table_B:

CREATE TRIGGER Delete_Trg ON Table_A
FOR DELETE
AS
Update Table_B
Set Field=GetDate()
Where Table_B.AutoNumber in (select AutoNumber from deleted)

Thanks for any help !
Paul
 
Hello... try this...

Code:
update table_b b
set b.field = get_date()
from deleted d where b.autonumber = d.autonumber

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top