Tricky if within a trigger

Last Post 07 Jan 2010 12:58 PM by timcronin. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
New Member
New Member

07 Jan 2010 12:58 PM
have tableA a which has an ID field, and a status field of either 'active' or inactive'
I have a related table, tableb which has the id field to match the record of the row in tableA, and it has a status flag of 'y' or 'n'. I need a trigger (has to work on mass updates so I can't use variables for my compare) If the status is changed from Active to inactive in tablea I need the corresponding record in tableb to have the flag changed to 'n'. I tried below, but not working. I was trying to do a compare using inserted versus deleted

alter trigger tim1 on tablea for update as
select from inserted inner join deleted on = where
inserted.status = 'inactive' and deleted.status = 'active'
if @@rowcount =1
update tableb
set status = 'N' from inserted
where =

Acceptable Use Policy