-
Trigger Ques
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 = '6/27/2001' and Ticker = @ticker) <> 0
begin
raiserror ('There exists current Portfolios for this ticker.',16,1)
ROLLBACK TRANSACTION
end
How can I assigned the ticker which is being changed to variable?
Thanks
Lara
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|