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
santhosh  konsanthosh kon 

How to delete inactive accounts by Batch Apex please send me some sample code?

Himanshu ParasharHimanshu Parashar
HI Santhosh,

Please find below code to delete inactive accounts
global class batchAccountUpdate implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id FROM Account where Active__c=false';
        return Database.getQueryLocator(query);
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         delete scope;
    global void finish(Database.BatchableContext BC) {

Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer.