Skip to content

👉 Join our Discord community.

How to Use SqlExec in Adobe Campaign Classic
> 999 views

How to Use SqlExec in Adobe Campaign Classic

View favourites

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 code. Loop over target data and assign voucher to recip…

🔒 Premium Subscriber Content

What you can learn with Premium

Unlock the full article to explore these topics in detail.

  • UPDATE
  • INSERT
  • DELETE
  • Best practices

Already a Premium subscriber? Log in to continue reading, or register to create your account.

You must log in and have a Premium Subscriber account to read the full article.

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

29,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
  • Monthly 15-Minute Call - Discuss any topic directly

Oh hi there 👋
I have a SSJS skill for you.

Sign up now to get an SSJS skill that can be used with your AI companion

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

Share With Others

The author
Marcel Szimonisz Platinum

Marcel Szimonisz

Marketing Automation Consultant

I specialize in solving marketing technology challenges, automating processes, and turning ideas into practical solutions with Salesforce Marketing Cloud and Adobe Campaign. Through MarTechNotes, I share technical guides and insights that make complex topics easier to understand

Latest badges
Weekend Regular Weekend Regular Profile Complete Profile Complete Simple Start Simple Start 5 Day Streak 5 Day Streak First Comment First Comment

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

Get exclusive tips, scripts and news

Choose your topics

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

Similar posts

Add to this article

Share your experience

Your contribution

Article history

What changed