function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raj R.Raj R. 

How to insert, delete, and update 50,000+ records using a trigger?

Here is the scenario:
• 50,000+ Accounts exist in the system
• The Account fields need to be copied over to a custom object(that is linked to its respective Account)
• A trigger can be used to insert, delete, and update records through the Sf user interface
 
I need to figure out a way to create 50, 000+ custom object records through a schedulable batch Apex class. Any ideas other than using Data Loader?
Best Answer chosen by Raj R.
Damien Phillippi033905702927186443Damien Phillippi033905702927186443
I think you have some confusion in your terminology... or about what you are saying.  That said, you can use an Apex batch for this.  It can query far more than 50k records and execute on them.  When batches execute, they execute on only 200 records at a time so you won't be hitting governor limits by using the batch.