🔥 500+ people already subscribed. Why not you? Get the monthly newsletter with handy code snippets, tips, and marketing automation insights.

background shape
background shape

How to Use SqlExec in Adobe Campaign Classic

SqlExec is a JSSP function in Adobe Campaign Classic that allows you to run raw SQL queries directly on the database. It supports INSERT, UPDATE, DELETE, and even SELECT statements—though it only returns the number of records affected, not the actual data.

To use SqlExec in Adobe Campaign Classic, your operator account must have the SQL SCRIPT EXECUTION right enabled. This permission—labeled sql in the rights configuration—grants the ability to execute raw SQL scripts directly on the database.

Without this right, attempting to use SqlExec() will result in a permissions error.

But hey… 🤫 let’s keep this between us.

There’s been a longstanding, quietly ignored security loophole in some deployments that technically allows a savvy operator to escalate privileges to admin. Yes, it’s a security issue. Yes, it’s been known for years. No, it still hasn’t been patched in some on-prem or poorly configured instances.

Now that you’re admin let’s do some work..

Syntax

var count = SqlExec(query [, value1, value2, …]);

Parameters

  • query (string): your SQL statement, with $(…) placeholders for any parameters.
  • value1, …: JavaScript values that will be bound to each placeholder, in order.

Return value

Returns the number of records updated or inserted in case of an UPDATE or INSERT SQL command. In case of select it returns number of records.

Substitution Variable Types

When constructing parameterized SQL queries using SqlExec, Adobe Campaign provides a set of variable placeholders. These ensure that the correct SQL data type is used when binding JavaScript variables to the SQL statement.

PlaceholderDescription
$(sz)string
$(m)memo (long text)
$(l)long (64-bit integer)
$(s)short (16-bit integer)
$(b)byte (8-bit integer)
$(d)double
$(f)float
$(ts)timestamp
$(dt)date
$(tm)time
$(dur)timespan in milliseconds

Auto-substitution placeholders

These placeholders do not require a value from JavaScript—they are automatically populated by the system. They can be used only with INSERT or UPDATE:

PlaceholderDescriptionOperation
$(id)Auto-generates a unique ID from the default sequenceINSERT
$(id:MySeqName)Generates ID using a custom named sequenceINSERT
$(curdate)Inserts current timestamp (date and time)INSERT, UPDATE

Examples

var sql = "INSERT INTO events (eventName, startTime, duration) VALUES ($(sz), $(ts), $(dur))";
SqlExec(sql, "Webinar", new Date(), 5400000);

Using auto primary key and current date as placeholder variable

var sql = "INSERT INTO logs (logId, created, userId) VALUES ($(id), $(curdate), $(l))";
SqlExec(sql, 2023);

For more records to process you can use loops.

for each (var client in clientList) {
  var sql = "INSERT INTO Reporting (sClientdesc, sClient) " +
            "VALUES ('" + client.description + "', '" + client.clientCode + "')";
  sqlExec(sql);
}

Here are some examples of using SqlExec to update or remove data from lists in Adobe Campaign—a task that can be quite tedious when done through standard workflow activities.

In the example below, we update the list directly using SQL.

UPDATE

Unassign vouchers by voucher

🔒 This content is for Premium Subsribers only.

Please log in to preview content. Log in or Register

You must log in and have a Premium Subscriber account to preview the content.

When upgrading, please use the same email address as your WordPress account so we can correctly link your Premium membership.

Please allow us a little time to process and upgrade your account after the purchase. If you need faster access or encounter any issues, feel free to contact us at info@martechnotes.com or through any other available channel.

To join the Discord community, please also provide your Discord username after subscribing, or reach out to us directly for access.

You can subscribe even before creating a WordPress account — your subscription will be linked to the email address used during checkout.

Premium Subscriber

19,99 € / Year

  • Free e-book with all revisions - 101 Adobe Campaign Classic (SFMC 101 in progress)
  • All Premium Subscriber Benefits - Exclusive blog content, weekly insights, and Discord community access
  • Lock in Your Price for a Full Year - Avoid future price increases
  • Limited Seats at This Price - Lock in early before it goes up

Oh hi there 👋
I have a FREE e-book for you.

Sign up now to get an in-depth analysis of Adobe and Salesforce Marketing Clouds!

We don’t spam! Read our privacy policy for more info.

Share With Others

Leave a Comment

Your email address will not be published. Required fields are marked *

MarTech consultant

Marcel Szimonisz

Marcel Szimonisz

I specialize in solving problems, automating processes, and driving innovation through major marketing automation platforms—particularly Salesforce Marketing Cloud and Adobe Campaign.

Get exclusive technical tips—only available on my blog.

We don’t spam! Read our privacy policy for more info.

Buy me a coffee
Related posts