DeleteDE()

Deletes rows from a data extension. This function doesn’t return any output.

You can use this function to delete rows from a data extension in an email. Use the DeleteData() function to delete rows in CloudPages, landing pages, microsites, and SMS messages in MobileConnect.

Availability

<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>❌ No</td> </tr> </table>

Syntax

DeleteDE(dataExt,
         columnName1, valueToDelete1,
         [columnName2, valueToDelete2 ...])

The DeleteDE() function has three parameters:

  • dataExt (string): Required. The name of the data extension that contains the data you want to delete.
  • columnName1 (string): Required. The name of the column to search for the data you want to delete.
  • valueToDelete1 (string): Required. The value that the function uses to determine which row to delete.

You can delete multiple rows in the same operation by appending column names and field values to the end of the function.

Usage

To use the function, first pass it the name of the data extension that contains the data that you want to delete. Next, pass it the name of the column to search for the data that you want to delete. Finally, pass the value that identifies the row you want to delete.

Deleting a Single Row

Imagine you have a Flights data extension that contains the data in this table.

Origin Dest Price PerBagSurcharge
IND NYC 100
IND LAX 200
IND SEA 500 25

To delete the row in which the value in the Dest column is "LAX", use this function.

%%[
  DeleteDE("Flights", "Dest", "LAX")
]%%

The function deletes the specified row, leaving this data in the data extension:

Origin Dest Price PerBagSurcharge
IND NYC 100
IND SEA 500 25

Deleting Multiple Rows

You can also use this function to delete multiple rows based on more than one set of criteria.

In this example, the Flights data extension from the earlier example has been expanded to include more data.

Origin Dest Price PerBagSurcharge
IND NYC 100
IND LAX 200
IND SEA 500 25
ORD SEA 525 10
ORD LAX 400
SEA SAN 300
SEA ATL 10
ATL AUS 350 10
STL KCA 5
STL ATL 200

To delete the rows in which the value in either the Origin or the Dest column is "ATL", use this function.

%%[
  DeleteDE("Flights", "Origin", "ATL", "Dest", "ATL")
]%%

The function deletes the specified rows, leaving this data in the data extension:

Origin Dest Price PerBagSurcharge
IND NYC 100
IND LAX 200
IND SEA 500 25
ORD SEA 525 10
ORD LAX 400
SEA SAN 300
STL KCA 5

See Also