Hello,

I want to create a trigger for Update on my table Companies . If the ticker for that table is updated or deleted it should check if ticker is used in Portfolio View. then it should stop the user to edit it or delete it. I'm new to SQl Server can anyone guide me that what is the mistake for the trigger is not firing on updates.


CREATE TRIGGER companies_ticker
ON Companies
FOR UPDATE
AS
declare @ticker varchar(20)
if UPDATE(Ticker)
select @ticker = ticker
from companies c INNER JOIN inserted i ON c.ticker = i.ticker

If (select count(*) from portfolioViewPT where date = &#39;6/27/2001&#39; and Ticker = @ticker) <> 0
begin
raiserror (&#39;There exists current Portfolios for this ticker.&#39;,16,1)
ROLLBACK TRANSACTION
end

How can I assigned the ticker which is being changed to variable?

Thanks

Lara