Our extensions: Salesforce NetSuite NEW Zoho SOON Session Manager NEW

Guides · NetSuite · 5 min read · Updated 28 Nov 2026

How to run a SuiteQL query in NetSuite

SuiteQL is NetSuite's SQL. It is much faster to write than a saved search for joins and counts, but NetSuite has no built-in window to type it into. These are your options.

Option 1: N/query in a script or the debugger

/**
 * @NApiVersion 2.1
 */
require(['N/query'], (query) => {
  const rows = query.runSuiteQL({
    query: 'SELECT id, companyname, email FROM customer WHERE isinactive = ? FETCH FIRST 50 ROWS ONLY',
    params: ['F']
  }).asMappedResults();
  log.debug('rows', rows);
});

Run it in the SuiteScript debugger, or put it in a Suitelet. Use runSuiteQLPaged for more than 5,000 rows.

Option 2: The REST API

POST to /services/rest/query/v1/suiteql with the header Prefer: transient and a body like {"q": "SELECT id, tranid FROM transaction WHERE type = 'SalesOrd'"}. Needs Token-Based Authentication or OAuth 2.0 and the REST Web Services feature.

Option 3: SuiteAnalytics Connect

With the SuiteAnalytics Connect feature you can connect a SQL client or Excel over ODBC/JDBC. Note that the Connect schema (NetSuite2.com) is the same as SuiteQL, but the feature may need a separate licence.

Finding table and column names

Open Setup → Records Catalog. Search for the record (for example Transaction) to see its SuiteQL table name, columns and joins. A few starters:

SELECT id, entityid, companyname FROM customer FETCH FIRST 20 ROWS ONLY
SELECT t.tranid, t.trandate, BUILTIN.DF(t.entity) AS customer, t.foreigntotal
FROM transaction t WHERE t.type = 'SalesOrd' AND t.trandate >= ADD_MONTHS(SYSDATE, -1)
SELECT scriptid, name, scripttype FROM script

In the browser, as your role (SuiteLens)

  1. Open NetSuite, click the SuiteLens button and open the SuiteQL tab.
  2. Write the query with the table browser and autocomplete, and press Run.
  3. Export the result to CSV or JSON.
Queries run as your own role, so results respect your permissions. SuiteLens is read-only; SuiteQL itself can only read data.

SuiteLens – Admin & Developer Toolkit for NetSuite
SuiteLens is free and read-only. It uses your own NetSuite login and role, works in Chrome and Edge, and your data stays in your browser.

Add to Chrome, free About SuiteLens

Related guides

How to see who changed a field in NetSuite How to find field internal IDs in NetSuite SuiteScript 2.1 upgrade checklist All guides →