I am running Batch Class for Migration of Records for Particular Object and I am storing Failed Records in an another Object. Now I have run the Batch and I got 1,00,000+ Records which are Failed. But Using the SOQL I can only get 50000 records. Following is the query for getting Failed Records.
SELECT Id, IsDeleted, Name, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Record_ID__c, Record_Name__c, Error__c,Batch_Result__r.Batch_Id__c FROM Batch_Status__c where Batch_Result__r.Batch_Id__c =:strBatchId
Thanks in Advance!!
Best Answer
You can get more than 50,000 using a Query Locator.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database_batch.htm
This documentation says you can query up to 50 million records: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
however, query locators have some risks where are well documented here: https://help.salesforce.com/apex/HTViewSolution?id=000004410&language=en_US