I can't find any examples anywhere of an upsert where the 2nd argument, "Number of column and value pairs in the subsequent selection arguments", is more than one.

I don't know how to format the request for multiple fields. For example, in the request below, one field is being updated - this works successfully. But if I want to update 2 fields, I will change the 2nd argument to 2, and then I don't know how to format the other arguments for which field to update and the value.

UPSERTDATA('Master Leads',1,'SubscriberKey',@SubscriberKey,'Optin',false)

1 Answer 1


You are partially correct.

The second argument in the function basically means the number of column and value pairs that will identify the needed row and if not found, would create a new row. It does not reflect the number of rows you would want to update as we have in the CreateSalesforceObject function.

Here is an example:

SET @SubscriberKey = 'SubKey'
SET @EmailAddress = '[email protected]'

UPSERTDATA('Master Leads', 2, 'SubscriberKey', @SubscriberKey, "EmailAddress", @EmailAddress, 'Optin', 'False')

/* If you want to upsert into more fields follow this pattern */
UPSERTDATA('Master Leads', 2, 'SubscriberKey', @SubscriberKey, "EmailAddress", @EmailAddress, 'Optin', 'False', 'Optout', 'True', 'Field3', 'Value3', 'Field4', 'Value4')

Which would translate that if function finds a row where "SubscriberKey" field has value = "SubKey" and "EmailAddress" field has value = "[email protected]" then it would update the row with "Optin" = "False". If one of the fields' values are not matched, then create a new row with stated information.

Once those 2 matching fields are identified, it does not matter how many fields you would try to update after.

  • I see, thank you for the clarification. So, if I wanted to update more than one field, it would be necessary to do multiple Upsert calls? Aug 6, 2021 at 16:50
  • You would need to have a separate UpsertData function per each Data Extension you would want to populate. If it is within one DE, then simply add more fields and values to the function. Check updated answer.
    – Niko
    Aug 6, 2021 at 17:31
  • 1
    awesome thats exactly what i was looking for -- so, it can just be a dozen (or whatever) key/value pairs as the closing arguments, and it'll update them all? That's great thank you! Aug 6, 2021 at 19:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .