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.
| 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 EQSA0240FOR UPDATE ASDECLARE @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 ENDSELECT @EQSId = (SELECT EQSEQUIPINDEX FROM Inserted)SELECT @EQSIdType = (SELECT EQSEQUIPTYPE FROM Inserted)if @EQSIdType not LIKE '%ST_%'beginreturnendBEGININSERT 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} |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-08-01 : 09:35:07
|
| Note: This comment does not answer your question.aaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhBrett8-)SELECT POST=NewId() |
 |
|
|
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 separateltyBut it's really hard to see aht/why you're doing...Brett8-)EDIT: Oh I forgot the miracle thing....there are none, and a trigger will fire only once PER event...SELECT POST=NewId() |
 |
|
|
|
|
|