Tricky if within a trigger

Last Post 07 Jan 2010 01:58 PM by timcronin. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
timcronin
New Member
New Member

--
07 Jan 2010 01: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 inserted.id from inserted inner join deleted on
inserted.id = deleted.id where
inserted.status = 'inactive' and deleted.status = 'active'
if @@rowcount =1
begin
update tableb
set status = 'N' from inserted
where tableb.id = inserted.id
end


You are not authorized to post a reply.

Acceptable Use Policy