Skip to content

Instantly share code, notes, and snippets.

@katydorjee
Created September 20, 2023 01:33
Show Gist options
  • Select an option

  • Save katydorjee/84d739a7ff5ce99c5da71475ddb70c6a to your computer and use it in GitHub Desktop.

Select an option

Save katydorjee/84d739a7ff5ce99c5da71475ddb70c6a to your computer and use it in GitHub Desktop.
Execute SQL query in SSJS.js
<script runat="server">
Platform.Load("Core","1.1.1");
try {
var qd = QueryDefinition.Init("SQL_Query_External_Key");
var campaignId = 'WINTER SALE'
var sql = "SELECT SubscriberKey, EmailAddress, FirstName, Status FROM MasterCustomer WHERE Status = '" + campaignId + "' FROM CampaignMaster";
var status = qd.Update({
Name : "SQL_Query_Name",
QueryText : sql
});
var status = qd.Perform();
}
catch (e) {
Write(Stringify(e));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment