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!.


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. – Nancy Jan 14 '14 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 '14 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. – Peter Knolle Jan 14 '14 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.

protected by Community Oct 8 '18 at 18:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.