---
schema_version: "1"
id: 61f75c96b279db612ec639a6bb0f86907cf25aa823f202da6698ff99e5afdcdd
title: Update a Query Activity
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/guides/mc-apis/updating_a_query_activity.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/updating_a_query_activity.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 67a3644fb1fc0f6e106482c1dac3dd73c74057135d8a7ace3c36ab6be75daaf6
products:
  - Marketing Cloud Engagement APIs and Programmatic Languages
  - Marketing Cloud
---
# Update a Query Activity

## Why Update a Query Activity

Updating a query activity allows you to change the criteria for the query that retrieves tracking information from your account. You can change the criteria to better refine your results or change the results you choose to receive entirely.

## How to Update a Query Activity

Use the sample code below as a model to create your own API call. You can’t retrieve the status or completion time of the query activity.

### Sample .NET Code

```
private void UpdateQueryAct(string strQAID, string strDEQuery, string strTargetGUID, string strOrigDE, string strDEImport)
{
    //Create the QueryDefinition Object
    QueryDefinition qd = new QueryDefinition();
    qd.ObjectID = strQAID;
    ////General Settings
    //qd.TargetUpdateType = "Overwrite";
    //qd.TargetType = "DE";
    //The actuall SQL
    string sql = "SELECT * FROM [" + ddlDataTemp.SelectedItem.Text + "] ";
    sql += "UNION ALL ";
    sql += "SELECT * FROM [" + strDEImport + "]";
    qd.QueryText = sql;
    //InteractionBaseObject ibo = new InteractionBaseObject();
    //ibo.CustomerKey = strDEQuery;//The DE to dump results to
    //ibo.Name = strDEQuery;
    //qd.DataExtensionTarget = ibo;
    InteractionBaseObject ibo = new InteractionBaseObject();
    ibo.CustomerKey = strTargetGUID;//The DE to dump results to
    ibo.Name = strDEQuery;
    qd.DataExtensionTarget = ibo;
    // Create the Import Definition
    string requestID = String.Empty;
    string status = String.Empty;
    UpdateResult[] uoResults = client.Update(null, new APIObject[] { qd }, out requestID, out status);
    //string strQAobjectID = uoResults[0].NewObjectID;
    lblMessage.Text += "<br/>UPDATED QueryDefinition: " + status;
}
```
