Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Trigger executing twice

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-01 : 07:47:05
Mo writes "Why is the following UPDATE trigger executing twice sometime?
Thanks.


CREATE TRIGGER trig_updateEQS
ON EQSA0240
FOR UPDATE
AS
DECLARE @EQSId VARCHAR(50)
DECLARE @EQSIdType VARCHAR(50)
IF NOT UPDATE(Equipment_Status) AND NOT UPDATE(Equipment_Condition) AND NOT UPDATE(Equipment_Division) AND NOT UPDATE(Equipment_Branch) AND NOT UPDATE(EQS_Operating_Location_I) AND NOT UPDATE(EQS_Owning_Location_Inde) AND NOT UPDATE(CUSTNMBR)
BEGIN
RETURN
END
SELECT @EQSId = (SELECT EQSEQUIPINDEX FROM Inserted)
SELECT @EQSIdType = (SELECT EQSEQUIPTYPE FROM Inserted)

if @EQSIdType not LIKE '%ST_%'
begin
return
end

BEGIN
INSERT INTO EQSEquipIndex(EQS_Id) Values(@EQSId )
END"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-08-01 : 08:03:48
Note: This comment does not answer your question.

Your trigger will not handle multi-row updates.

Jay White
{0}
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-08-01 : 09:35:07
Note: This comment does not answer your question.


aaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh



Brett

8-)

SELECT POST=NewId()
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-08-01 : 09:37:03
No really though..if Many rows are updated, you will only handle the last update...you need to find the key value, and do each row separatelty


But it's really hard to see aht/why you're doing...



Brett

8-)

EDIT: Oh I forgot the miracle thing....there are none, and a trigger will fire only once PER event...



SELECT POST=NewId()
Go to Top of Page
   

- Advertisement -