4
Update [Select ID from Account]; //Updates all the record when there is no actual update.

I wrote a trigger on account after update in such a way that the account name is not null then populate the name+number combination in another field.

In the above statement there is no field change but it got populated for all account.

1
8

The short answer is: It forces an update on all records (accounts) in the database. The query returns every single account from the database and the update DML statement is obvious.

Regardless of whether there is a field change, the DML will occur and your trigger will run.

This will work as long as you have less than 10,000 records in the database which is the limit of records you can perform a DML on. After that you might want to consider a batch or define a WHERE clause in your query to only return those records you really need to update...

1
  • 1
    One additional consideration, it will work as long as the criteria on your trigger field update are met. It is common to check for changes to a field before applying any logic.
    – Adrian Larson
    Feb 22 '17 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.