How to Mass Delete Records in Salesforce [2024 Edition]

 Editor’s note: This article has been updated for accuracy and comprehensiveness in October 2023.

At least once, we have come across a situation when we needed to quickly mass delete data from Salesforce, for example, accounts, contacts, leads, or any other standard/custom objects that were previously imported incorrectly or those objects, that we simply want to delete out of Salesforce forever. For example, we have made a bulk upload of leads into Salesforce but would like to return everything. In this article, we describe how to do it with ease.

It’s worth mentioning that Salesforce has its own tool for mass deleting accounts, leads, contacts, etc. This built-in tool is used for deleting standard Salesforce objects; however, it doesn’t cover all the scenarios required by users.

Unlike Apex Data Loader, Skyvia is a cloud-based solution, which needs minimal configuration and only a web browser to be accessed from anywhere. With Skyvia, you can bulk delete leads, contacts, or any custom or standard object from Salesforce, using either Query or Skyvia Data Loader.

Prior to mass deleting any Salesforce records, you can play it safe and back up data using Skyvia Backup Product. Backed-up data can be viewed and later exported or restored directly to Salesforce via web browser from the Skyvia interface. We offer up to 1 GB of storage for free to our clients.

Below we describe 5 ways how you can easily bulk delete data from Salesforce. The first two rely on the standard functions embedded in Salesforce for mass deleting data. The other three methods involve Skyvia for bulk data removal and demonstrate the advantages it brings to users. Your deep technical knowledge isn’t required.

explore pricing

Table of contents

  1. Mass Delete Records in Salesforce Lightning
  2. Bulk Delete Records in Salesforce Classic
  3. Mass Delete Salesforce Records Using SQL
  4. Bulk Delete Salesforce Records by CSV Using Data Loader
  5. Batch Remove Salesforce Contacts by Filters Using Data Loader

Mass Delete Records in Salesforce Lightning

The first thing to stress here is that Salesforce Lightning is a comprehensive suite with a new design and an advanced set of features. It’s based on the classic version of Salesforce, though offers some extra functions allowing users to streamline their sales funnels by developing apps with embedded mechanisms. Salesforce Lightning also simplifies many operations, so it’s easier to handle them compared to the classic version.

Bulk deleting contacts, leads, and other records is the standard function included by default in Salesforce.

To mass delete records in Salesforce Lightning, proceed as follows:

  1. Go to your Salesforce account and make sure that it’s in Lightning mode. If not, click on Switch to Lightning Experience in the upper bar.
Salesforce Lightning
  1. Click on the cog icon and select the Setup option.
  2. In the Quick Find box, type “Mass Delete Records’. Click on the appropriate option found.
  3. In the Mass Delete Records window, select whether to delete accounts, activities, contacts, cases, leads, products, or reports.
  4. Indicate the criteria for the records to be deleted and click Search.
  5. On the list of found records, select all or some of the records and click Delete.
Salesforce menu

Bulk Delete Records in Salesforce Classic

The name of the tool speaks for itself – Salesforce Classic is the standard version of the application. It’s been in use for years and is well-known to seasoned users of Salesforce. Even though the Lightning framework appears automatically upon landing in the application, some users still prefer the classic representation of Salesforce.

To mass delete records in Salesforce Classic, proceed as follows:

  1. Go to your Salesforce account and make sure that it’s in Classic mode. If not, click the profile icon and select Switch to Salesforce Classic.
  2. Click on Setup in the upper menu.
  3. In the Quick Find box, type “Mass Delete Records’. Click on the appropriate option found.
  4. In the Mass Delete Records window, select whether to delete accounts, activities, contacts, cases, leads, products, or reports.
  5. Indicate the criteria for the records to be deleted and click Search.
  6. On the list of found records, select all or some of the records and click Delete.
Salesforce menu

Salesforce allows users to delete records in bulk. However, the maximum number of records to remove at once is 250, so it might be necessary to perform dozens of such operations to eliminate thousands of records. This is not convenient and usually time-consuming, so the utilization of alternative services becomes inevitable in such cases.

Discover best pricing

Mass Delete Salesforce Records Using SQL

Skyvia Query is an online SQL client and query builder tool that allows querying and managing cloud and relational data with SQL statements. It is a perfect solution for users who are familiar with SQL, as you simply enter SQL statements via the code editor and execute the query. If you are not so good at SQL, you can try to use our visual query builder. To read more about it, visit our Skyvia documentation.

Except for DELETE statements, Skyvia Query also supports SQL SELECT, INSERT, and UPDATE for cloud sources. For relational databases, Skyvia can execute all the statements supported by the database, including DDL statements.

Let us get started with creating a query. First, we register a free Skyvia account. Such registration requires no credit card. Second, after registering, we create a query simply by clicking +NEW in the top menu and selecting SQL in the Query column.

Mass Delete Salesforce Records Using SQL 1

The query editor opens. To query data, first, you need to create a connection to Salesforce by clicking the +New connection link (in case you have not created it yet) or select the already created Salesforce connection from the drop-down list on the left.

SQL Query Skyvia

After the Salesforce connection is selected, enter the DELETE statement directly into the code editor. You can use advanced SQL features to determine criteria for records to delete in the SQL WHERE clause. You can add multiple conditions, unite them with logical operators, use SQLite SQL functions, and even use IN clauses with subqueries.

If you don’t want to compose the WHERE clause manually, you can use the visual query builder to configure filters for the corresponding SELECT statement visually. If necessary, you may run this SELECT statement to be sure that it returns the records you need. Then you can copy this WHERE clause to your DELETE statement with slight modifications.

In our example, we bulk delete leads from Salesforce created after November 3, 2020. We enter the following statement: DELETE FROM Lead WHERE CreatedDate > ‘2020-11-03 00:00:00’. After we’ve entered the statement, we click the Execute button to run it.

Mass Delete Salesforce Records Using SQL 4

The query result field displays records to be deleted. Before deleting them, you can check whether the displayed records are correct, and only after that, click the Apply All button. That helps not to worry about removing wrong leads.

If you plan to reuse this DELETE statement in the future, click the Save button to save and name the query. You can also add a description to your query if necessary.

In the same way, you can mass delete custom object records from Salesforce. As mentioned above, Skyvia supports deleting both standard and custom objects. For this, you need to know a bit of SQL or use our visual query builder to add a necessary condition.

What is also convenient is that Skyvia offers 5 free queries per day according to the free query pricing plan. Such a number of queries can be enough if you need to mass delete records occasionally.

try Skyvia

Bulk Delete Salesforce Records by CSV Using Data Loader

Mass deleting Salesforce records via CSV files is probably the most frequently requested method among thousands of users on the Internet. This method is really useful if you have hundreds (if not thousands) of records in a CSV file, which need to be removed in the fastest possible way. Below we show how to do it with Skyvia Data Loader via import operation. In our example, we mass delete accounts from Salesforce. Following our example, you can mass delete tasks from Salesforce, mass delete leads, reports or any other data in exactly the same way.

For this, you need to create an import package. To create an import package, click +NEW in the top menu and select Import in the Integration column.

Import scenario Skyvia

When the package editor opens, the source type CSV upload manually is selected by default, which is what we actually need. Next, you should select the Salesforce connection from the drop-down list as a target. If you haven’t created the Salesforce connection yet, click +New connection at the bottom of the drop-down list. You can read more on how to create a connection in our Salesforce import tutorial.

When both connections are selected, proceed with adding a task to the import package. For this, click the Add new link on the right.

In the opened Task Editor, click browse and upload your CSV, check whether the CSV Separator is selected correctly, and look through the columns of the CSV file. When everything is okay, click Next step to adjust target settings.

In the Target drop-down list, select the Account object. Then, select the operation type for the task (Delete operation for our case) and proceed further.

In the last step of the task editor, you should map the source columns to the target columns. If you have account IDs, you simply map the source column to the target column by selecting ID in the drop-down list.

When you do not have account IDs, or they are unknown, you can use Target Lookup. The Lookup mapping allows getting them directly from target tables by other fields, identifying rows, such as names, for example. If you have the Name field in your CSV file, the target lookup is right for you.

So, in our example, we use the Target Lookup mapping too. To configure such a lookup, perform the following steps:

  1. In the Lookup Object drop-down list, select a target object to get the value from (in our example, we select Name).
  2. In the Result Column drop-down list, select a column from the Lookup Object to get the result value that will be assigned to the mapped target column (in our example, we select Id as a result column).
  3. In the drop-down list, select the target lookup key column. Two new drop-down lists are displayed. The first one determines how to select the lookup object rows. It is set to Column by default.
  4. Finally, in the bottom drop-down list, select the source column, the value of which must be equal to the lookup key column value (in our example, it is Name).

To finish adding a task, click Save.

In the package editor, you will see an added task with accounts you want to delete according to the CSV list. Click Create to create an import package and then click Run to execute account deletion.

Batch Remove Salesforce Contacts by Filters Using Data Loader

If the records for deleting can be received from Salesforce itself, Skyvia offers an alternative and much simpler way to mass delete them. You just need to create an import package, select the same Salesforce connection as source and target in the package editor, select the same Salesforce object to delete data from, apply a certain condition according to which your data will be deleted, and run the package. It’s as simple as that, and no CSV files are required.

Let us mass delete contacts from Salesforce as an example. You create an import package in the same way as described above. When the package editor opens, click Data Source database or cloud app under Source Type and select the Salesforce connection as a source. Then, select the Salesforce connection as a target. When both connections are selected, proceed with adding a task to the import package. After clicking the Add new link, you are dropped into the Task Editor window.

Mass Delete Salesforce Records by Filters Using Data Loader 1

On the Source Definition tab of the Task Editor window, select Contact in the Source drop-down list.

In the Filter section, click the +Condition button on the right and set the condition according to which records will be deleted. In the first drop-down list, we select the Contact object. In the second drop-down list, we select CreatedDate. In the third drop-down list, we select “the greater than sign >” as we want to delete contacts after a certain date. In the fourth drop-down list, we choose an appropriate date using the opened calendar box. In our example, we delete contacts created after 10.08.2020 00:00:00.

Skyvia doesn’t limit you to a single condition only. You can mass delete data by adding any other condition that better meets your personal or business needs. In Skyvia, you can also add multiple filters, which can be united in groups. Each group may consist of several filters and/or subgroups united with a logical operator (AND or OR). You can read more about filtering options in the Filter Settings topic.

When everything is ready on this tab, click Next step to adjust target settings.

Mass Delete Salesforce Records by Filters Using Data Loader 2

From the Target drop-down list, select the Contact object. Then, select the operation type for the task (Delete operation for our case).

Click Next step to proceed with mapping. Target columns, which are marked as Required, must be mapped in order for the task to be valid. In our case, it is the ID column, and it has already been mapped automatically by Skyvia. To finish adding a task, click Save.

Mass Delete Salesforce Records by Filters Using Data Loader 3

In the editor, you’ll see an added task with contacts you want to delete according to the set condition. Click Create to create an Import scenario and then click Run to execute deletion.

In the same way you create an Import integration to mass delete opportunities in Salesforce, you can do any other object you want.

Conclusion

In this article, we’ve tried our best to describe in detail five ways to mass delete Salesforce records. The first two ways might be fine if the number of records to eliminate isn’t high. Methods using Skyvia are considerably faster, especially when it comes to a large number of records. 

You can decide on your own, which way is the most suitable for your business needs. We hope this article was helpful for you. What other data integration operations may be useful for you to read in our blog? Leave your comment or feedback – we will appreciate it!

Anna Tereshchenko
Anna Tereshchenko
Technical Writer

TOPICS

BY CONNECTORS

Skyvia podcast