Created
September 20, 2023 01:33
-
-
Save katydorjee/84d739a7ff5ce99c5da71475ddb70c6a to your computer and use it in GitHub Desktop.
Execute SQL query in SSJS.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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