With the help of script activity shared by Eliot here, similarly I am trying to update the target DE as All Subscribers in a SQL query activity.
Here is the updated code I am using in the script, but for some reason it is not working for me. Can someone please suggest what am I doing wrong here?
<script language="javascript" runat="server">
Platform.Load('Core', '1');
var prox = new Script.Util.WSProxy();
var queryStr = '';
queryStr += 'SELECT DISTINCT';
queryStr += '\nsub.SubscriberKey AS [Subscriber Key]';
queryStr += '\nsub.EmailAddress AS [Email Address]';
queryStr += '\nFROM _Sent s';
queryStr += '\nLEFT JOIN _Subscribers sub';
queryStr += '\n ON s.SubscriberKey = sub.SubscriberKey';
queryStr += '\nLEFT JOIN _Open o';
queryStr += '\n ON s.SubscriberKey = o.SubscriberKey';
queryStr += '\nWHERE o.SubscriberKey IS NULL';
var queryDef = {
CustomerKey: 'QUERY_ACTIVITY_EXTERNAL_KEY', //Replaced with the SQL query activity external key
ObjectID: 'QUERY_ACTIVITY_URL_ID', //Replaced with the SQL query activity URL ID
QueryText: queryStr,
TargetType: 'DE',
TargetUpdateType: 'Update',
DataExtensionTarget: {
CustomerKey: 'All Subscribers - xxxx', //Replaced with the All Subscribers External Key
Name: 'All Subscribers'
}
};
var updateQuery = prox.updateItem('QueryDefinition', queryDef);
Write('result: ' + Stringify(updateQuery))
</script>