0

Is it possible to perform a Delete from a Data Extension using Query or something? Like we have Insert/Update option in a query, I would like to delete.

I know this can done using API but is that the only way to perform automatic deletions from a data extension?

2

Yes, via AMPScript: (https://help.marketingcloud.com/en/documentation/exacttarget/content/ampscript/ampscript_syntax_guide/data_extension_ampscript_functions/)

DeleteData(S1, S2, S3) Deletes rows in a data extension with column values specified in name value pairs. The number of rows affected is returned. You can also use this function with SMS data.

Arguments

S1 Data extension from which to delete the specified row S2 Name of the column to use to identify the rows to delete. S3 Value to use to identify the rows to delete. Example

DeleteData("SendDE", "_SubscriberKey","12345") The system deletes rows in the SendDE data extension whose _SubscriberKey column contains the value 12345 and returns the number of rows that were deleted.

DeleteDE(S1, S2, S3) Deletes rows in a data extension with column values specified in name value pairs. No value is returned. This function is for use with email messages at send time only.

Arguments

S1 The name of the data extension from which to delete the specified row S2 Name of the column to use to identify the rows to delete. S3 Value to use to identify the rows to delete. Example

DeleteDE("SendDE", "_SubscriberKey","12345")

or via SSJS: (https://help.marketingcloud.com/en/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/platform_server_side_javascript_functions/interacting_with_data_extensions_using_the_function_object/)

DeleteData(S1,A1,A2) Use this method to delete information from a data extension as indicated by the array containing the listed column name and value pairs. You can include multiple column name and value pairs in a single call. You can use this method in non-sending contexts, such as landing pages. This call returns the number of rows modified.

Arguments

S1 - String value indicating the name of the data extension A1 - Array containing the names of the columns from the data extension A2 - Array containing the relevant values in the data extension Example

<script runat="server">
      var rows = Platform.Function.DeleteData('CustomerData',['LastName'],['Smith']);
 </script>

This example deletes the rows from the data extension with the LastName value of Smith.

DeleteDE(S1,A1,A2) Use this method to delete information from a data extension as indicated by the array containing the listed column name and value pairs. You can include multiple column name and value pairs in a single call. You can use this method in sendable contexts, such as email messages.

Arguments

S1 - String value indicating the name of the data extension A1 - Array containing the names of the columns from the data extension A2 - Array containing the relevant values in the data extension Example

<script runat="server">
      var rows = Platform.Function.DeleteDE('CustomerData',['LastName'],['Smith']);
 </script>

This example deletes the rows from the data extension with the LastName value of Smith.

  • Thank You! Have a follow up question too - So I am receiving a file from an external system which has rows that need to be deleted from a Data Extension. How can I process that file? – Maneesh Jun 8 '16 at 15:08
  • Simplest would be to run it through a server-side script PRIOR to SFMC receiving the file, but outside of that your simplest option is to import full file into a Data Extension (DE) and then run a Query or filter on it to remove the unnecessary entries and upload results to a new DE that you use. – Gortonington Jun 8 '16 at 15:11
  • I am totally new to this Java Script but I quickly skimmed through the documentation and below is what I think I need to do with SSJS - Under Interaction >> Script ... Write whatever script is needed and automate the process using Automation Studio. Is that right ? – Maneesh Jun 8 '16 at 15:24
  • you can write a SSJS snippet interaction to put in an Automation, but you will likely need to go through SFMC support (or your AE) to get this turned on and please note that SSJS is very slow, so if it is time sensitive, realize this may not be the best solution. – Gortonington Jun 8 '16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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