I'm fairly new to Salesforce. I'm curious if I can use a SOQL query to do a batch update? I have experience with SQL, and I know this would be easy using SQL with something like Oracle or Postgres or MySQL. But can I do this with SOQL?

Here is the request that I was asked to complete:

On the Lead object, find the field "Most Recent Campaign." Then find the parent campaign for that campaign. If the parent's campaign name is "Via Terra 2022" or "Via Terra 2023" then the Most Recent Campaign field on the Lead should simply be "Via Terra."

I'm adding a Flow so this is done automatically in the future, but I also need to update the older, existing records.

I'm curious if I can accomplish this by running a SOQL statement in the Developer Console?

  • Do you mean you have created record trigger flow for this. You need this logic for existing logic? Commented Feb 22, 2023 at 6:37
  • 2
    SOQL is for querying only. Updates are done using DML which is separate. Note that you can only update up to 10000 records in a given transaction so for large volume you must use an alternative such as a Batchable implementation.
    – Phil W
    Commented Feb 22, 2023 at 7:03
  • SOQL stands for the Salesforce Object Querying Language and as such only supports query and not insert or update statements like SQL, for those actions you need to make DML statements through either flow, apex or the API if you are doing it by dataload
    – Gilhil
    Commented Feb 22, 2023 at 8:08

1 Answer 1


If the requirement is to simply update all the older records, you can do that as a single dataload operation.

If the requirement is such that you will need to continuously process large data volume, you can explore creating a batch job.

Using Batch Apex : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm

Running a SOQL will only fetch records, whereas you would need to perform the update via script.

A simple Data load would be better, since you can fetch the results from the query, export it to excel, verify the records, update the excel with the right values and then import it via data load.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .