DeleteData()

Deletes rows from a data extension, and returns the number of rows deleted.

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

The DeleteData() 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.

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.

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

OriginDestPricePerBagSurcharge
INDNYC100
INDLAX200
INDSEA50025

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

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

OriginDestPricePerBagSurcharge
INDNYC100
INDSEA50025

The function returns 1, indicating that it deleted one row.

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.

OriginDestPricePerBagSurcharge
INDNYC100
INDLAX200
INDSEA50025
ORDSEA52510
ORDLAX400
SEASAN300
SEAATL10
ATLAUS35010
STLKCA5
STLATL200

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

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

OriginDestPricePerBagSurcharge
INDNYC100
INDLAX200
INDSEA50025
ORDSEA52510
ORDLAX400
SEASAN300
STLKCA5

The function returns 3, indicating that it deleted three rows.