Trigger updating same table sql server
(If it cannot be that the row already has those values then leave that code out; but I've seen large UPDATES where the trigger re-updates them, changing nothing, but bloating the log and taking more CPU !! Answer will NOT be true if either is Null I still don't think you should be using NOLOCK. Answer will NOT be true if either is Null I still don't think you should be using NOLOCK.
)No sense updating if the row already has those values. Looks like you are just using it "as a matter of course"What does you UPDATE statement look like? Looks like you are just using it "as a matter of course"What does you UPDATE statement look like?
When you assign the value from those tables to variables, which of the many values will get assigned is not predictable.
Even if your business logic will result in only one row being updated, relying on that is not a good idea.2.
This is what I came up with for the update trigger:--IF UPDATE(Answer Modified) BEGIN UPDATE T SET T. If this is an AFTER trigger this cannot be, the Update will already have been applied, so the columns in INSERTED will be the same as in the main table.
Answer Modified = 1, CUT = 0 FROM atbl_Bids_BEQregister (NOLOCK) T INNER JOIN Inserted I ON I. This WHERE clause will mean that zero rows are updated No sense updating if the row already has those values.
You do this by not including the columns in the SET clause of the UPDATE statement.Looks like what you are trying to do is use recursive triggers. You can check if it is turned off by running this query: If it is indeed turned off, and you want to turn it on, it would be advisable to do a lot of testing and evaluation to see what if any impact that would have on other triggers.3.I did not completely follow the logic that you are trying to implement, but it seemed like you are trying to recursively update a column until it settles down to some value.INSTEAD OF UPDATE triggers can be defined on a view or table to replace the standard action of the UPDATE statement.Typically, the INSTEAD OF UPDATE trigger is defined on a view to modify data in one or more base tables.