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 

1private void UpdateQueryAct(string strQAID, string strDEQuery, string strTargetGUID, string strOrigDE, string strDEImport)
2{
3    //Create the QueryDefinition Object
4    QueryDefinition qd = new QueryDefinition();
5    qd.ObjectID = strQAID;
6    ////General Settings
7    //qd.TargetUpdateType = "Overwrite";
8    //qd.TargetType = "DE";
9    //The actuall SQL
10    string sql = "SELECT * FROM [" + ddlDataTemp.SelectedItem.Text + "] ";
11    sql += "UNION ALL ";
12    sql += "SELECT * FROM [" + strDEImport + "]";
13    qd.QueryText = sql;
14    //InteractionBaseObject ibo = new InteractionBaseObject();
15    //ibo.CustomerKey = strDEQuery;//The DE to dump results to
16    //ibo.Name = strDEQuery;
17    //qd.DataExtensionTarget = ibo;
18    InteractionBaseObject ibo = new InteractionBaseObject();
19    ibo.CustomerKey = strTargetGUID;//The DE to dump results to
20    ibo.Name = strDEQuery;
21    qd.DataExtensionTarget = ibo;
22    // Create the Import Definition
23    string requestID = String.Empty;
24    string status = String.Empty;
25    UpdateResult[] uoResults = client.Update(null, new APIObject[] { qd }, out requestID, out status);
26    //string strQAobjectID = uoResults[0].NewObjectID;
27    lblMessage.Text += "<br/>UPDATED QueryDefinition: " + status;
28}