This is a solution for those who do not know anything about Cloud Pages or how to send a SOAP message to the MC API.
Combining the other answers, as well as a script by Zuzanna Jarczynska that I also found, I came to this script:
<script runat="server">
Platform.Load("Core", "1");
try {
var prox = new Script.Util.WSProxy();
var targetDE = 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'; // External key of DE where search results are stored
var logDE = DataExtension.Init(targetDE);
function getQueries(objectType, cols) {
var objectType = "QueryDefinition",
cols = ["Name", "Description", "QueryText", "ObjectID", "DataExtensionTarget.Name", "DataExtensionTarget.CustomerKey"],
filter = {
Property: "QueryText",
SimpleOperator: "like",
Value: "whatever you are looking for" // The text that you are looking for in all of your SQL queries
}
moreData = true,
reqID = null,
numItems = 0;
while (moreData) {
moreData = false;
var data = reqID == null ? prox.retrieve(objectType, cols, filter) : prox.getNextBatch(objectType, reqID);
if (data != null) {
moreData = data.HasMoreRows;
reqID = data.RequestID;
if (data && data.Results) {
for (var i = 0; i < data.Results.length; i++) {
logDE.Rows.Add({
Name: data.Results[i].DataExtensionTarget.Name,
DEKey: data.Results[i].DataExtensionTarget.CustomerKey,
ActivityName: data.Results[i].Name,
ActivityType: "Query",
ActivityDescription: data.Results[i].Description
});
numItems++;
}
}
}
}
Write("<br />" + numItems + " total " + objectType + "<br>");
}
getQueries(objectType, cols)
} catch (e) {
Write(Stringify(e));
}
</script>
This must be stored as a script in Automation Studio Activities. And then run, of course (via Run once).
But! It requires a Data Extension in which the results are stored. You have to create this first. Columns are: Name
, DEKey
, ActivityName
, ActivityType
, ActivityDescription
. These are all text fields, size 250.
As SQL queries can easily be larger than 250 characters, this script does not store the queries itself. But the name of the query (in Name
) points you in the right direction.