SOQL Query to Find Products With a Blank ProductCode

Find products with an empty ProductCode using SOQL, including the NULL syntax, blank-string gotcha, and a count-first workflow.

Updated 2026-09-09

Blank required-in-practice fields are the quiet tax on every report. This query lists the products where ProductCode was never filled in.

The product object is named Product2 in the API even though the UI calls it Product, which trips up most first-time SOQL queries.

The query

In SOQL, NULL is a keyword - it is never quoted and never compared with IS NULL.

Products missing ProductCode
SELECT Id, Name, ProductCode, Family
FROM Product2
WHERE ProductCode = NULL
ORDER BY CreatedDate DESC
LIMIT 200

Count first, then export

Before exporting, size the problem. If the count is in the hundreds it is a cleanup task; if it is in the tens of thousands it is a process problem upstream.

How big is the gap?
SELECT COUNT()
FROM Product2
WHERE ProductCode = NULL

Text fields can be blank without being NULL

An imported empty string is not the same as a null value in every context. For text fields, check both to be safe.

Null or empty
SELECT Id, Name, ProductCode, Family
FROM Product2
WHERE ProductCode = NULL OR ProductCode = ''

Common mistakes to avoid

  • Use the API name Product2, not the UI label - the two differ on several standard objects.
  • Wrap literal text values in single quotes; date literals such as LAST_N_DAYS:30 must stay unquoted.
  • Run the query in a sandbox first if it feeds a bulk update - a WHERE clause that is one character off can select the whole table.
  • != NULL is the correct way to ask for populated values; there is no IS NOT NULL in SOQL.
  • Formula and roll-up fields cannot always be filtered on - if the query errors, the field is not filterable.

Run it faster with TurboKit

Finding the blanks is easy; fixing them means exporting, editing, and re-importing the same rows.

TurboKit's AI SOQL builder lets you describe the result you want in plain English, returns the query, and exports the rows to CSV or Excel in the same panel - without leaving the Salesforce tab you are already on.

Frequently asked questions

Does SOQL support IS NULL?
No. SOQL uses = NULL and != NULL. IS NULL is SQL syntax and returns a malformed-query error in Salesforce.
Can I filter Product2 on a blank picklist?
Yes - an unset picklist compares equal to NULL. A picklist set to a value that was later removed from the value set is still a non-null string, so it will not appear.
Why do some fields error when I filter on NULL?
Non-filterable fields - long text areas, some formula fields, and encrypted fields - cannot appear in a WHERE clause at all.

More from the SOQL Library

Related reading