What are the ways to do Data Migration in Production Organization. I am trying to do something like

  1. Migrate data from Account lookup field in Lead to new lookup field in the same object (lookup for a custom object)
  2. Move data from one object's fields to another custom object.
  3. Change all null values of a field to 'Default'

How to achieve this in salesforce. I know SOQL queries can only be used for selecting records and not for inserting/updating. I find using Apex Data Loader as a good solution. I tried exporting data from the object, modified values, created new csv to support new objects and copied data and imported back into salesforce. Is this the right way of doing it?Please suggest me a solution. I am new to salesforce!.

3 Answers 3


In my opinion, it is better to achieve the migration using the Data Loader, when you can, than it is to write Apex, but as with everything it depends on the specific scenario.

Benefits of using the Data Loader:

  • You don't have to worry about coding errors when you use the Data Loader.
  • You don't have to worry about limits as much. For example, if you are migrating a sizeable number of records you'll quickly run into limits with the number of records returned by your SOQL query.

That being said, there are some times when Apex might be the way to go.

  • You have complex business logic that isn't as simple as exporting one Object's fields and importing to another. In this case, I'd recommend creating a Batch Apex job, unit testing it, and testing it in a sandbox prior to production.
  • You have an Object that has a few (e.g., 10) records and you are copying a value from one field to another field. Anonymous Apex would be reasonable to me. With this small data set, it's simple, easily verifiable, and you likely won't hit limits.
  • We have thousands of records in each object. I think Data Loader seems to be fit for the job. Thanks for the suggestion.
    – Maria
    Jan 14, 2014 at 9:36

You can easily use a bit of Anonymous Apex to do this. You'll be writing a apex statements to select your data, and insert data into other objects.

  • 2
    This has a general limit of a few thousand records at a time, but it is far faster than exporting, updating, and inserting. And you can just execute it multiple times until all the data is processed.
    – sfdcfox
    Jan 13, 2014 at 19:55
  • 2
    Just be careful if you go the route of executing multiple times when there are lots of records. I've seen situations where people don't plan for how they'll detect some records have already been processed, how they'll handle/record errors or exceptions, etc. Jan 14, 2014 at 0:10

There are several ways to do salesforce data migration

  • Open APIs (SOAP, REST, Streaming, etc.)
  • Bulk Data Transfer API
  • Data integration tools like Mulesoft, Talend etc.

You must log in to answer this question.

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